练习一:
def normalize(name): return name[0].upper() + ''.join(list(map(lambda s: s.lower(), name[1:])))
练习二:
def prod(L): return reduce(lambda x, y: x * y, L)
练习三:
def str2float(s): DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} d = s.index('.') i = reduce(lambda x, y: 10 * x + y, list(map(lambda x: DIGITS[x], s[:d]))) f = reduce(lambda x, y: 0.1 * x + y, list(map(lambda x: DIGITS[x], s[:d:-1]))) * 0.1 return i + f
Sign in to make a reply
用户6182518782_73465
练习一:
练习二:
练习三: