Discuss / Python / 我宣布我最短

我宣布我最短

Topic source

第一题

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

第二题

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

第三题

def str2float(s):
    a,b=s.split('.')
    a1=reduce(lambda x,y:10*x+y,map(int,a))
    b1=reduce(lambda x,y:0.1*x+y,map(int,b[::-1]))/10
    return a1+b1

  • 1

Reply