您的位置:首页 > 其它

一道数学题

2016-09-08 23:22 127 查看
儿子的数学题

2 2 2 =6

3 3 3 =6

4 4 4=6

.

.

.

9 9 9 =6

要求是填上符号,等式成立。好吧,我又偷懒了。

for i in map(str,range(1,11)):
for j in range(10000):
c=random.choice(["+","-","*","/","**0.5",""])
b=random.choice(["+","-","*","/","**0.5",""])
e=random.choice(["**0.5",""])
if c=="**0.5":
c=c+random.choice(["+","-","*","/"])
if b=="**0.5":
b=b+random.choice(["+","-","*","/"])
if eval(i+c+i+b+i+e)==6:
print i+c+i+b+i
break
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: