Discuss / Python / 作业

作业

Topic source

松霜杨雪

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

作业1: def normalize(name): return name.capitalize()

作业2: def str2float(s): DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} def chr2num(s): return DIGITS[s] def fn10(x, y): return x 10 + y l = s.split('.') n = len(l[1]) return reduce(fn10, map(chr2num, l[0])) + (reduce(fn10, map(chr2num, l[1])) pow(10, -n))

松霜杨雪

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

’ 没有打出来 x * 10 + y


  • 1

Reply