Discuss / Python / .......................................

.......................................

Topic source

Paul--Curry

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

from functools import reduce def char2num(s): return {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '.':'.'}[s] def dot(s): t = list(map(char2num, s)) ll = s.find('.'); if ll != -1: t.remove('.') g=reduce(lambda x, y: 10 x + y,t) if ll != -1: r = len(t) - ll g = g / (10*r) return g print(dot('0.0456700'))

Paul--Curry

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

10**r


  • 1

Reply