首页 > 编程语言 > 详细

python基础一之while循环随机猜数字

时间:2019-01-19 16:52:10      阅读:232      评论:0      收藏:0      [点我收藏+]
 1 # Author:"Mamba"
 2 
 3 import random
 4 setNum = random.randint(1,10)
 5 #print(setNum)
 6 count = 0
 7 while count == 0:
 8     print(let`us play guess number games)
 9     print(your have three times ,now begin)
10     guess = int(input("please input your number:"))
11     if guess == setNum:
12         print("great ,so clever you are")
13         break
14     elif guess < setNum:
15         print({0}{1}{2}{3}{4}.format(sorry,, the number you guessed is small,, and you have , (2 - count),  more chances.))
16     else :
17         print({0}{1}{2}{3}{4}.format(sorry,, You guessed a big number,, and you have , (2 - count), more chances.))
18     count =count +1
19     break
20 while  count < 3:
21     guess = int(input("please input your number again:"))
22     if guess == setNum:
23         print("great ,so clever you are")
24         break
25     elif guess < setNum:
26         print({0}{1}{2}{3}{4}.format(sorry,, the number you guessed is small,, so you have , (2 - count),  more chances.))
27     else :
28         print( {0}{1}{2}{3}{4}.format(sorry,, You guessed a big number,, so you have , (2 - count),  more chances.))
29     count =count +1
30 else :
31     print("you have tried too many times ,game over")

 

python基础一之while循环随机猜数字

原文:https://www.cnblogs.com/mamba-T/p/10292160.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!