码迷,mamicode.com
首页 > 其他好文 > 详细

猜年龄小游戏

时间:2017-07-07 11:46:51      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:logs   blog   技术分享   int   流程   输入   while   tin   年龄   

基本要求:

  允许用户猜三次,如果没有猜对,提示用户是否继续,输入Y或y继续,输入N或n退出程序,如果猜对直接退出程序。

流程如下:

技术分享

 1 cj=24
 2 x=0
 3 while True :
 4     if x >=3 :
 5        p=input(‘continue please input (Y)y or  N(n)>>:   ‘)  #提示输入Y(y)或N(n)继续或者退出
 6        if p == ‘y‘ or p == ‘Y‘ :
 7            x=0
 8            continue
 9        elif p == ‘n‘ or p == ‘N‘ :
10            exit()
11        else:
12            print(‘please input (Y)y or  N(n)‘)
13            continue
14     q=int(input(‘please input age :  ‘))
15     if q ==cj :
16         print(‘so  good!!!‘)
17         exit()
18     if q > cj :
19         print (‘so   big!‘)
20         x+=1
21         continue
22     if q < cj :
23         x+=1
24         print(‘so small!!‘)
25         continue

 

猜年龄小游戏

标签:logs   blog   技术分享   int   流程   输入   while   tin   年龄   

原文地址:http://www.cnblogs.com/ikere/p/7131047.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!