用PythonCharm编写一个猜年龄的小游戏!!!(10分钟)

前端之家收集整理的这篇文章主要介绍了用PythonCharm编写一个猜年龄的小游戏!!!(10分钟)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
import random #把random模块调用出来
age = random.randint(10,25)用rand.randint制造一个随机数表
count = 0
while count < 3:共有三次机会
    n = int(input('Guess the age:'))输入用户通过键盘敲打的数据
    if n > age:
        print(Try smaller,你还有%s次机会'%(2-count))
        count += 1
    elif n <Try bigger,1)">'%(2 - count))
        count += 1
    else:
        Yes,you get it')
        break结束循环
print(age)

本文首发于python黑洞网博客园同步更新

 

猜你在找的Python相关文章