Discuss / Python / bbb

啧啧ghz

#1 Created at ... [Delete] [Delete and Lock User]

-- coding: utf-8 --

def normalize(nm): nm = nm[0].upper() + nm[1:].lower() return nm

#测试1; L1 = ['adam', 'LISA', 'barT'] L2 = list(map(normalize, L1)) print(L2)

from functools import reduce

def prod(L): def chenfa(x, y): return x * y return reduce (chenfa, L)

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


  • 1

Reply