Discuss / Python / 学习中。。。

学习中。。。

Topic source

我是iboy啊

#1 Created at ... [Delete] [Delete and Lock User]

第一题:

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

def prod(L): return reduce(lambda x, y:x*y, L) 第三题: DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}

def str2float(s): def fn(x, y): return 10x+y def char2num(s): if s != '.': return DIGITS[s] return reduce(fn, list(l for l in map(char2num, s) if l != None))/pow(10,len(s)-s.index('.')-1)


  • 1

Reply