设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
查看: 10000|回复: 0
打印 上一主题 下一主题

猜数字,小程序,第一次成功,值得庆祝!

[复制链接]

5

主题

0

好友

134

积分

注册会员

Rank: 2

跳转到指定楼层
楼主
发表于 2015-12-10 14:58:27 |只看该作者 |倒序浏览
想实现的结果:
COM:猜猜我现在想的数字是什么?嗯,你想的数字是:3
COM:Your answer is too small.
嗯,你想的数字是:8
COM:Your answer is too small.
嗯,你想的数字是:11
COM:Your answer is too large.
嗯,你想的数字是:10
COM:BINGO!!!

Process finished with exit code 0


代码:
#!/usr/bin/python
# -*- coding=utf-8 -*-
#author:我是一个小菜鸟

word="COM:猜猜我现在想的数字是什么?"
print(word)         #用的版本是python3.5.0
#digit=int(input("please input:"))

while 1:            #while循环语句
    digit=int(input("嗯,你想的数字是:"))   #输入一个数字
    if digit<10:
        print("COM:Your answer is too small.")
        continue              #跳过这个条件
    elif digit>10:
        print("COM:Your answer is too large.")
        continue
    else:
        print("COM:BINGO!!!")
        break                #结束while循环


畏缩不前,徒伤时光,况大局无恙
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

QQ|手机版|Archiver|Crossin的编程教室 ( 苏ICP备15063769号  

GMT+8, 2024-5-1 12:29 , Processed in 0.016089 second(s), 25 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部