环境python3.6 ,jupyter,都出错
代码:
print ("water flower number is :",)
for a in range(100,1000):
x,y,z = a/100,a/10%10,a%10
print("a=%d,x=%d,y=%d,z=%d"%(a,x,y,z))
count= x**3 + y**3 + z**3
print("x**3=%d,y**3=%d,z**3=%d"%(x**3,y**3,z**3))
print("count=%d"%(count))
print("---------------------")
if x**3 + y**3 + z**3 == a:
print ("is flower =%d,"%a,)
结果输出:见红色部分,a=113时开始出现计算错误
water flower number is :
a=100,x=1,y=0,z=0
x**3=1,y**3=0,z**3=0
count=1
---------------------
a=101,x=1,y=0,z=1
x**3=1,y**3=0,z**3=1
count=2
---------------------
a=102,x=1,y=0,z=2
x**3=1,y**3=0,z**3=8
count=9
---------------------
a=103,x=1,y=0,z=3
x**3=1,y**3=0,z**3=27
count=28
---------------------
a=104,x=1,y=0,z=4
x**3=1,y**3=0,z**3=64
count=65
---------------------
a=105,x=1,y=0,z=5
x**3=1,y**3=0,z**3=125
count=126
---------------------
a=106,x=1,y=0,z=6
x**3=1,y**3=0,z**3=216
count=217
---------------------
a=107,x=1,y=0,z=7
x**3=1,y**3=0,z**3=343
count=344
---------------------
a=108,x=1,y=0,z=8
x**3=1,y**3=0,z**3=512
count=513
---------------------
a=109,x=1,y=0,z=9
x**3=1,y**3=0,z**3=729
count=731
---------------------
a=110,x=1,y=1,z=0
x**3=1,y**3=1,z**3=0
count=2
---------------------
a=111,x=1,y=1,z=1
x**3=1,y**3=1,z**3=1
count=3
---------------------
a=112,x=1,y=1,z=2
x**3=1,y**3=1,z**3=8
count=11
---------------------
a=113,x=1,y=1,z=3
x**3=1,y**3=2,z**3=27 ,从这里开始,y=1,y**3怎么等于2了,后面开始就全是错的
count=30
---------------------
a=114,x=1,y=1,z=4
x**3=1,y**3=2,z**3=64
count=68
---------------------
a=115,x=1,y=1,z=5
x**3=1,y**3=3,z**3=125
count=129
---------------------
a=116,x=1,y=1,z=6
x**3=1,y**3=4,z**3=216
count=221
---------------------
a=117,x=1,y=1,z=7
x**3=1,y**3=4,z**3=343
count=349
---------------------
a=118,x=1,y=1,z=8
x**3=1,y**3=5,z**3=512
count=519
---------------------
a=119,x=1,y=1,z=9
x**3=1,y**3=6,z**3=729
count=737
---------------------
a=120,x=1,y=2,z=0
x**3=1,y**3=8,z**3=0
count=9
---------------------
a=121,x=1,y=2,z=1
x**3=1,y**3=9,z**3=1
count=12
---------------------
a=122,x=1,y=2,z=2
x**3=1,y**3=10,z**3=8
count=20
---------------------
a=123,x=1,y=2,z=3
x**3=1,y**3=12,z**3=27
count=41
---------------------
a=124,x=1,y=2,z=4
x**3=1,y**3=13,z**3=64
count=79
---------------------
a=125,x=1,y=2,z=5
x**3=1,y**3=15,z**3=125
count=142
---------------------
a=126,x=1,y=2,z=6
x**3=2,y**3=17,z**3=216
count=235
---------------------
a=127,x=1,y=2,z=7
x**3=2,y**3=19,z**3=343
count=364
---------------------
a=128,x=1,y=2,z=8
x**3=2,y**3=21,z**3=512
count=536
---------------------
a=129,x=1,y=2,z=9
x**3=2,y**3=24,z**3=729
count=755
---------------------
a=130,x=1,y=3,z=0
x**3=2,y**3=27,z**3=0
count=29
---------------------
a=131,x=1,y=3,z=1
x**3=2,y**3=29,z**3=1
count=33
---------------------
a=132,x=1,y=3,z=2
x**3=2,y**3=32,z**3=8
count=43
---------------------
a=133,x=1,y=3,z=3
x**3=2,y**3=35,z**3=27
count=65
---------------------
a=134,x=1,y=3,z=4
x**3=2,y**3=39,z**3=64
count=105
---------------------
a=135,x=1,y=3,z=5
x**3=2,y**3=42,z**3=125
count=170
---------------------
a=136,x=1,y=3,z=6
x**3=2,y**3=46,z**3=216
count=265
---------------------
a=137,x=1,y=3,z=7
x**3=2,y**3=50,z**3=343
count=396
---------------------
a=138,x=1,y=3,z=8
x**3=2,y**3=54,z**3=512
count=569
---------------------
a=139,x=1,y=3,z=9
x**3=2,y**3=59,z**3=729
count=791