关于作者

Discuss / Python / 交作业了~

交作业了~

Topic source

hexymaster

#1 Created at ...

第一题:

def normalize(name): name=name.lower().capitalize() return name

第二题

from functools import reduce
def prod(L): def multi(x,y): return x*y return reduce(multi,L)

第三题

from functools import reduce
def str2float(s): def find(s): return s.find('.') def clear(s): return s.replace('.','') def char2num(s): return {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}[s] def fn(x,y): return x10+y return 10**(-(len(s)-1-find(s)))reduce(fn,map(char2num,clear(s)))

竹聿Simon

#2 Created at ...

capitalize()本身是将字符串的第一个字母变成大写,其他字母变小写。所以不需要lower()了。

火星的时代666

#3 Created at ...

666


  • 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.