Discuss / Python / 先做两题,明天继续

先做两题,明天继续

Topic source

from functools import reduce

def normalize(name): b = a[0].upper() + a[1:].lower()

return b

L1 = ['adam', 'LISA', 'barT']

L2 = list(map(normalize, L1))

print(L2)

def prod(L):

def aa(x,y):

    return x*y

return reduce(aa,L)

print('3 5 7 * 9 =', prod([3, 5, 7, 9]))

if prod([3, 5, 7, 9]) == 945: print('测试成功!') else: print('测试失败!')


  • 1

Reply