python_for_asl/Exercise/exercise-4.3.py
2025-08-06 02:04:35 +08:00

14 lines
No EOL
441 B
Python

import random
# 我们来写一个猜数字的小游戏
# 生成一个随机的1-100整数作为答案
answer = random.randint(1, 100)
game_over = False
count = 0
while not game_over:
print(f"你已经猜了{count}次,请输入下一次猜测")
count += 1
guess = int(input())
print(f"你的猜测是{guess}")
# 如果猜对了,输出“猜对了”并结束游戏。否则输出“猜大了”或者“猜小了”