加入收藏 | 设为首页 | 会员中心 | 我要投稿 北几岛 (https://www.beijidao.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2021-05-21 05:31:30 所属栏目:大数据 来源: https://www.jb51.cc
导读: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次
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黑洞网,博客园同步更新

?

(编辑:北几岛)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读