关于作者

Discuss / Python / 练习

练习

Topic source

温布利不坑爹

#1 Created at ...

练习1

def normalize(name):
    return name.capitalize()

练习2

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

练习3

def str2float(s):
    def char2num(c):
        return {'0' : 0, '1' : 1, '2' : 2, '3' : 3, '4' : 4, '5' : 5, '6' : 6, '7' : 7, '8' : 8, '9' : 9}[c]
    def num2float(x, y):
        return x * 10 + y
    l = s.split('.')
    l1 = reduce(num2float, list(map(char2num, l[0])))
    l2 = reduce(num2float, list(map(char2num, l[1])))/10**len(l[1])

    return l1 + l2

  • 1

Reply

WARNING: You are using an old browser that does not support HTML5. Please choose a modern browser (Chrome / Microsoft Edge / Firefox / Sarafi) to get a good experience.