第一第二题作业
Topic source在此插入代码
a=s.find('.')
b=len(s)-a-1
s1=list(s)
s1.remove('.')
def f(x,y):
return x*10+y
def char2num(s1):
return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9}[s1]
s2=reduce(f, map(char2num, s1))
s2=s2/pow(10,b)
return s2
- 1
方大侠百宝箱
def normalize(*name): L2 = [s.capitalize() for s in name ] return L2 L1 = ['adam', 'LISA', 'barT'] L2 = list(map(normalize, L1)) print (L2)
from functools import reduce def prod(L): def xxx(x,y): return x * y return reduce(xxx,L)
print('3 5 7 * 9 =', prod([3, 5, 7, 9]))