Python-100-Days/Day01-15/code/Day05/guess.py

27 lines
594 B
Python
Raw Normal View History

2018-03-02 00:09:06 +08:00
"""
猜数字游戏
计算机出一个1~100之间的随机数由人来猜
计算机根据人猜的数字分别给出提示大一点/小一点/猜对了
Version: 0.1
Author: 骆昊
Date: 2018-03-02
"""
import random
answer = random.randint(1, 100)
counter = 0
while True:
2019-05-03 21:17:36 +08:00
counter += 1
number = int(input('请输入: '))
if number < answer:
print('大一点')
elif number > answer:
print('小一点')
else:
print('恭喜你猜对了!')
break
2018-03-02 00:09:06 +08:00
print('你总共猜了%d' % counter)
if counter > 7:
2019-05-03 21:17:36 +08:00
print('你的智商余额明显不足')