九州体育网 - 十年信誉网站

关于作者

Discuss / Python / 作业

作业

Topic source

血手幽灵123123

#1 Created at ...

第一题:

def normalize(name): return name[0].upper()+name.lower()[1:] 第二题:

def prod(L): return reduce(fn,L)

def fn(x,y): return x*y 第三题:

def DIGITS(n): return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'.':'.'}[n]

def fn(x,y): return x*10+y if y!='.' else x

def power(x,n=2): s = 1 while n>0: n-=1 s = s * x return s

def str2float(s): return reduce(fn,map(DIGITS,s))/power(10,s.index('.'))


  • 1

Reply

WARNING: You are using an old browser that does not support HTML5. Please choose a modern browser (Chrome / Microsoft Edge / Firefox / Sarafi) to get a good experience.