1.水仙花
for x in range(100, 1000): low = x%10 mid = x//10%10 hig = x//100 if low ** 3 + mid **3 + hig **3 == x : print("%d is" % x)
2.整数反转
a = int(input("整数")) reverse = 0 while a > 0 : reverse = reverse * 10 + a %10 a//=10 print("reverse is %d" % reverse)
3.百钱白鸡
for x in range(20): for y in range(33): z = 100 - x -y if x*5 + y*3 + z/3 == 100: print("x is %d, y is %d, z is %d" % (x,y,z))
本文为看恩吧原创文章,转载无需和我联系,但请注明来自knsay.com