Python 009作业求水仙花数下面的代码错在哪?跪求
temp = range(100,1000)temp // 100 = a
temp //10 - a*10 = b
temp -a*100-b*10 = c
while temp:
if temp == a^3 + b^3 + c^3:
print(temp,'是水仙花数!')
else:
print('')
temp += 1
错误比较多,
range要用for遍历
赋值是变量名在左边
while循环无意义
for temp in range(100,1000):
a = temp // 100
b = temp //10 - a*10
c = temp -a*100-b*10
if temp == a**3 + b**3 + c**3:
print(temp,'是水仙花数!')
页:
[1]