while True: num = input("please input number:") num = int(num) if 100 <= num <= 999: a = num // 100 b = num % 100 // 10 c = num % 10 # print(a, b, c) sum = a ** 3 + b ** 3 + c ** 3 if num == sum: notice = " 是水仙花数" print("The number %d" % (num) + notice) else: notice = " 不是水仙花数" print("The number %d" % (num) + notice) # print(num+notice) else: print("Your input is error,please reput:")
Python小白实例(八)——水仙花数
最新推荐文章于 2024-09-15 22:23:28 发布