first commit
This commit is contained in:
parent
abc6526143
commit
26631f9b48
24 changed files with 1089 additions and 1 deletions
14
Exercise/exercise-4.3.py
Normal file
14
Exercise/exercise-4.3.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
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}")
|
||||
# 如果猜对了,输出“猜对了”并结束游戏。否则输出“猜大了”或者“猜小了”
|
||||
Loading…
Add table
Add a link
Reference in a new issue