python初学者的猜数字游戏,python初学者猜数字,python初学者的猜数
python初学者的猜数字游戏,python初学者猜数字,python初学者的猜数
python初学者的猜数字游戏,根据猜的次数打分python初学者的猜数字游戏代码片段
1.[代码]猜数字游戏,有次数限制并且打分
import randomnum = random.randint(0,100)times = 0print "Number(0,100) guess game"print "You will have 10 times to guess"print "Guess out of range will game over immediately!"guess = int(raw_input("guess a number:"))times = times + 1 while 0 <= guess <= 100: if times == 10: if guess > num: print "Too high,The number is",num print "Guess times over,game over!" elif guess < num: print "Too Low,The number is",num print "Guess times over,game over!" else: print "You guess it.The number is:",num score = 10*(11-times) print "times is:",times print "Your score is",score break else: if guess > num: print "Too high,guess again!" elif guess < num: print "Too Low,guess again!" else: print "You guess it.The number is:",num score = 10*(11-times) print "times is:",times print "Your score is",score break guess = int(raw_input("guess a number:")) times = times + 1 else: print "Your guess is out of range!Game over!"
编橙之家文章,
相关内容
- python统计nginx日志ip和流量,pythonnginx日志ip,python统计
- python将uuid压缩成64位编码,pythonuuid,<python将uuid
- python获得 Alexa网站排名,pythonalexa,<python获得 Al
- 用Python实现最基本的电话本,Python实现电话,<用Pyth
- 用python代码科学上Google,python代码google,用python代码科学
- python终端播放音乐同步显示本地或网络歌词,python播放
- python获取情敌电脑内照片神器,,python获取情敌电脑
- python随机搜索并打开该路径内的文件,,标签: <pyt
- 基于python Selenium的用户登录自动化测试,pythonselenium,使
- 通过python hp ilo对机器的状态进行监控,pythonilo,<通过
评论关闭