简单小游戏
作者:互联网
import random
rang1 = int(input("请设置本局游戏的最小值:"))
rang2 = int(input("请设置本局游戏的最大值:"))
num = random.randint(rang1,rang2)
guess = "guess"
print("数字猜谜游戏!")
i = 0
while guess != num:
i += 1
guess = int(input("请输入你猜的数字:"))
if guess == num:
print("恭喜,你猜对了!")
elif guess < num:
print("你猜的数小了...")
else:
print("你猜的数大了...")
print("你总共猜了%d" %i + "次",end = '')
标签:guess,num,本局,int,小游戏,简单,print,input 来源: https://blog.csdn.net/weixin_47367390/article/details/117339523