Discuss / Python / 打卡

打卡

Topic source

Tim_Ho_

#1 Created at ... [Delete] [Delete and Lock User]
#1
def normalize(name):
    Name = name.upper()[0] + name.lower()[1:]
    return Name

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

#3
    DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}
    def char2num(s):
        return DIGITS[s]
    L = s.split('.')
    return reduce(lambda x, y: x * 10 + y, map(char2num, L[0])) + reduce(lambda x, y: x * 10 + y, map(char2num, L[1])) / 10**len(L[1])


  • 1

Reply