鱼C论坛

 找回密码
 立即注册
查看: 2891|回复: 0

[技术交流] 新手专用

[复制链接]
发表于 2020-3-18 08:53:57 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. import random
  2. secret = random.randint(1,50)
  3. print("-------------Guess number game--------------")
  4. temp = input("Guess what number I am thinking in 1-50 (try 5 times) : ")
  5. guess = int(temp)
  6. if guess == secret:
  7.         print("You get it!")
  8.         print("It was it!")
  9. else:
  10.         if guess > secret:
  11.             print("It was bigger than the number")
  12.         else:
  13.             print("It was smaller than the number")
  14. counts = 4
  15. if guess != secret:
  16.         while counts > 0:
  17.                 temp = input("Incorrect ,try again: ")
  18.                 guess = int(temp)
  19.                 if guess == secret:
  20.                         print("You get it!")
  21.                         print("It was it! ")
  22.                 else:
  23.                         if guess > secret:
  24.                             print("It was bigger than the number")
  25.                         else:
  26.                             print("It was smaller than the number")
  27.                 counts = counts - 1
  28. print("Game Over^_^")
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-5-14 14:21

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表