python编写猜数字游戏

print("====================")
print("      猜数字游戏")
print("====================")
import random

random=random.randint(1,10)
name=input("请输入你的名字")
print("欢迎"+name+"来到猜数字游戏")
while 1:
    tem=int(input("请输入你猜的数字:"))
    if tem < random :
        print("你猜的数字小了,请再猜一次")
    elif tem>random :
        print("你猜的数字大了,请再猜一次")
    else:
        print("恭喜你回答正确!")
        break
print("游戏结束")

猜你喜欢

转载自www.cnblogs.com/hph1728390/p/12196587.html