Write a function called "findMin" which takes an list as input, and returns
the minimum element in the input list.
这题倒是对了
虽然不知道有没有可能会有意外情况
def findMin(list):
for i in list:
print(min(list))
return
print("undefined")
findMin([1, 2, 5, 6, 99, 4, 5]); # returns 1
findMin([]); # returns undefined
findMin([1, 6, 0, 33, 44, 88, -10]); # returns -10
昨天写的
Write a function called "table" which takes an input n, and prints out n x 1
to n x 9
def table(n):
for i in range(0, 10):
print(f"{n} x {i} = {n*i}")
table(3)
# 3 x 1 = 3
# 3 x 2 = 6
# ...
# 3 x 9 = 27
Write a function called "table9to9" that prints out the multiplication table:
def table9to9():
for i in range(1, 10):
for j in range(1, 10):
print(f"{i} x {j} ={i*j}")
table9to9();
# 1 x 1 = 1
# 1 x 2 = 2
# 1 x 3 = 3
# ...
# 1 x 9 = 9
# 2 x 1 = 2
# 2 x 2 = 4
# ...
# 9 x 9 = 81