这是一个玩烂的游戏,几乎每本书都会有
import random secret=random.randint(1,100)#随机选择一个数字 guess=0 tries=0 print("hi,I have a very important secret,It is a number from 1 to 99,\ I will give you six times to guess.if you guess right,I will give\ you some prize,however if you guess wrong,you must run ten minutes\ on the backgrand") while guess != secret and tries<=6: guess=input("what's your guess") guess=int(guess) if guess < secret: print("your number is a little low") if guess > secret: print("your number is a little high") tries=tries+1 if guess==secret: print("congrulations,your number is right,your prize is a little dog") else: print("no more guess") print("the secret number is" +"secret")
以上是代码,仅供参考