小九九 发表于 2023-8-14 16:04:34

编写一个 猜数字游戏

import random

number = random.randint(1, 100)
guess = int(input("猜一个1到100之间的数字:"))

while guess != number:
    if guess > number:
      print("猜的数字太大了!")
    else:
      print("猜的数字太小了!")
    guess = int(input("再猜一次:"))

print("恭喜你,猜对了!")


页: [1]
查看完整版本: 编写一个 猜数字游戏