设为首页收藏本站

Crossin的编程教室

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

【Python 第9课】random

[复制链接]

0

主题

0

好友

12

积分

新手上路

Rank: 1

楼主
发表于 2013-12-26 15:54:29 |显示全部楼层
本帖最后由 roy 于 2013-12-26 15:56 编辑

学习中。。。
#coding UTF-8
from random import randint
Answer=randint(1,100)
totoal=10
left=0
num=0
time=0  
print 'plese input the number you  guess!!!'
while int(num) != Answer:
    while time<=totoal :
        num=int(input());  
        time+=1
        left=totoal-time
        if num>Answer:
            print 'too   big,you have['+str(left)+']times'
        elif num<Answer:
            print 'too small,you have['+str(left)+']times'
        elif num==Answer:
            print 'congratulations you get it!'            
    else:
        print 'sorry,you have get more then 3 time,can not try again!'
   
回复

使用道具 举报

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

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

GMT+8, 2024-5-4 15:52 , Processed in 0.023643 second(s), 22 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部