Discuss / Python / 作业

作业

Topic source

恁麻了批

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

第一题

def normalize(L):

    names = [str.upper(v) if i == 0 else str.lower(v) for i, v in enumerate(L)]

    return ''.join(names)

第二题

def prod(L):

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

第三题

def str2float(s):

    return reduce(lambda x,y: x * 10 + y, map(int,s.split('.')[0])) + reduce(lambda x, y: x / 10 + y, map(int, s.split('.')[1][::-1])) / 10


  • 1

Reply