Discuss / Python / 不用title和float完成

不用title和float完成

Topic source

居士先生

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

#第一题:

return name[:1].upper()+name[1:].lower() #不用title,第一个字母大写,其余字母小写。

#第二题:

return reduce(lambda x,y:x*y,L)

#第三题:

d1 = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}

return reduce(lambda x,y:x*10+y,map(lambda n:d1[n],s.replace(".","")))/(10**(len(s)-1-s.index('.')))


  • 1

Reply