python学习小程序
import random n = random.randint(0,10) count = 0 while count < 3: age = int(input('请输入你要猜的年龄:')) if age < n: print('抱歉,太小了') elif age > n: print('抱歉,太大了') else: print('恭喜您,猜对了') k = input('你是否要再来一局?') if k == '是': n = random.randint(0,10) count = -1 else: print('游戏结束,谢谢') break count += 1 if count == 3: m = input('你是否要继续游戏?') if m =='是': print('恭喜你,复活成功,游戏继续') count = 0 else: break print('我的真实年龄是:',n)
猜年龄小游戏