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

30 lines
555 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:
counter += 1
number = int(input('请输入: '))
if number < answer:
print('大一点')
elif number > answer:
print('小一点')
else:
print('恭喜你猜对了!')
break
print('你总共猜了%d' % counter)
if counter > 7:
print('你的智商余额明显不足')