def isSXH(n):
a = n % 10
b = n % 100 // 10
c = n // 100
sum = pow(a, 3) + pow(b, 3) + pow(c, 3)
if sum == n:
return True
else:
return False
isSXH = isSXH(int(input("请输入一个三位数:")))
if isSXH:
print("是水仙花")
else:
print("不是水仙花")
原文:https://www.cnblogs.com/ZhaoBa/p/14732358.html