from functools import reduce
def prod(L):
return reduce(lambda x, y: x * y, L)
print('3 * 5 * 7 * 9 =', prod([3, 5, 7, 9]))
第三题:
from functools import reduce
def str2float(s):
return reduce(lambda x, y: x * 10 + y, [int(c) for c in s if c != '.']) / pow(10, len(s) - s.index('.') - 1)
print('str2float(\'123.456789\') =', str2float('123.456789'))
林金壕
第一题:
第二题:
第三题: