- 帖子
- 2
- 精华
- 0
- 积分
- 6
- 阅读权限
- 10
- 注册时间
- 2019-8-17
- 最后登录
- 2019-8-17
|
import random
# secert是1-100之间的随机数
secert = random.randint(1,100)
guess = 0
tries = 0
print("AHOY!I AM THE DREAD PIRATE ROBERS,AND I HAVW A SECRET!")
print("IT IS A NUMBER FROM 1 TO 99. I WILL GIVE YOU 6 TRIES.")
# tries<6 来统计输入的数(guess)是否和secert的值相等
while guess!= secert and tries < 6:
print('secert:', secert)
guess = int(input("WHAT IS YER GUESS?"))
if guess<secert:
print("TOO LAW")
elif guess>secert:
print("TOO HIGH")
elif guess==secert:
print("YOU FOUND MY SECERT!")
# 输入guess不等于secert时,tries的值加1
tries = tries + 1
print("NO MORE GUESSES! BETTER LUCK NEXT TIME, MATEY!")
print("THE SECERT NUMBER WAS", secert)
# 加两条注释和一个print语句,你看一下 |
|