Discuss / Python / day6.交作业(请原谅今天的懒惰)

day6.交作业(请原谅今天的懒惰)

Topic source

小太郎tail

#1 Created at ... [Delete] [Delete and Lock User]
  • #作业1
    def normalize(name):
    return name[0].upper()+name[1:].lower()
    L1=input('请输入:')
    L2=list(map(normalize,L1.split()))
    print (L2)

  • #作业2
    from functools import reduce
    def prod(L):
    def fn(x,y):
    return x*y
    return reduce(fn,L)
    L=list(map(int,input('请输入:').split()))
    print(prod(L))

  • #作业3
    from functools import reduce
    def str2float(s):
    a,b=s.split('.')
    x1=reduce(lambda x,y:x*10+y,map(int,a))
    y1=reduce(lambda x,y:x*0.1+y,map(int,b[::-1]))/10
    return x1+y1
    s=input('请输入:')
    print(str2float(s))

大大MAX哥,请分享下你成功的秘诀


  • 1

Reply