Discuss / Python / 交个作业

交个作业

Topic source

Project71

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

第一题:

def normalize(name):

    #除第一个字母全变小写

    def add(x,y):

        res = x+y

        return res

    def lower1(i):

        res2 = i.lower()

        return res2

    info2 = reduce(add,map(lower1,name[1:]))

    #把大写插入开头

    upperword = name[0].upper()

    info3 = upperword+info2

    return info3

L1 = ['adam', 'LISA', 'barT']

L2 = list(map(normalize, L1))

print(L2)

第二题:

def prod(L):

    def cheng(x,y):

        res = x*y

        return res

    return reduce(cheng,L)

第三题:

    #第三题不会啊

    flo = float(s)

    return flo


  • 1

Reply