import random
ran = int(random.randint(1,100))
print(ran)
while True:
num = int(input(“请输入0-100间的数字:”))
if num < 0 or num > 100:
input(“对不起,输入有误”)
else:
if num > ran:
print(“大了”)
elif num < ran:
print(“小了”)
elif num == ran:
print(“猜对了!”)
break
import random
suijishu = random.randint(1,10)
print(" 猜数字 ")
while True:
guess = int(input(“请输入一个1~10的数字:”))
if guess >10 or guess <0:
print(“输入有误,请重新输入”)
elif guess > suijishu:
print(“猜大了”)
elif guess < suijishu:
print(“猜小了”)
elif guess == suijishu:
print(“恭喜你,猜对了”)
break
print(“游戏结束”)