|

楼主 |
发表于 2018-7-18 10:14:55
|
显示全部楼层
本帖最后由 千殇 于 2018-7-19 09:43 编辑
- """第一个小游戏 v3.0.0"""
- """增加了随机数"""
- """增加了当用户输入错误类型的时候,及时提醒用户重新输入,防止程序崩溃。"""
- import random
- times = 3
- secret = random.randint(1,10)
- print('-----------i love yu c office-----------')
- guess = 0
- print("不妨猜一下小甲鱼现在心里想的是哪个数字:",end = '')
- while (guess != secret) and times > 0:
- temp = input()
- if temp.isdigit():
- guess = int(temp)
- if guess == secret:
- print("握草,你是小甲鱼心里的蛔虫吗?!")
- print("哼,猜中了也没有奖励!")
- else:
- if guess > secret:
- print("brother, 大了大了")
- else:
- print("haha~ 小了小了")
- if times > 1:
- print("再试一次吧:",end = '')
- else:
- print('机会用光')
- else:
- print("抱歉,你的输入有误,请输入一个整数:",end = '')
- times = times - 1
- print("game over")
- input()
复制代码 |
|