1.定义两个函数,求和函数和最大函数

def add(x, y):
return x + y def maxnum(x, y):
return x if x > y else y
lst= [2, 4, 6, 9,8,98,34,90]
def reduce_(function, liste , initial):
result = initial
for num in liste:
result = function(result, num)
return result print(reduce_(maxnum, lst, 0))
print(reduce_(add, lst, 0))
05-25 16:00