Discuss / Python / 一起写作业

一起写作业

Topic source

icicle4

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

负数判断简单就省略吧。。。

在此插入代码
def power(x, n):
    s = 1
    while n > 0:
        n = n - 1
        s = s * x
    return s
if s.find('.')!=-1: 
    n=len(s)-s.find('.')
else:
    n=0
def trans(s):
    return{'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'0':0}[s]
return power(0.1,n)*reduce(lambda x, y: x * 10 + y,map(trans,s[:s.find('.')]+s[s.find('.')+1:]))

  • 1

Reply