jiayu -猜数字

# 猜数字:电脑出一个随机1-100数字,我们输入一个数字,判断是否猜中


# 电脑出一个1-100的随机数字
import random
computer = random.randint(1,100)
for w in range(25):
# 我们猜一个数字
    we = input("猜一个数字")
    we = int(we)
    # 判断有没有猜中
    if we == computer:
        print("天选之人")
        break
    elif we > computer:
        print("猜大了")
    elif we < computer:
        print("猜小了")


print("你一共猜了"+str(w+1)+"次")



发布了305 篇原创文章 · 获赞 18 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/houlaos/article/details/104210038