zoukankan      html  css  js  c++  java
  • 猜年龄游戏升级版

    猜年龄游戏升级版:任性玩

    先限定5次机会,并给出相应的偏大偏小提示,后面添加条件5次之后是否继续猜

     1 age = 33
     2 count = 5
     3 while count > 0:
     4     print('您有{_count}次猜测机会!'.format(_count=count))
     5     guess_age = int(input('guess age:'))
     6     if guess_age == age:
     7         print('Yes,you got it.')
     8         break
     9     elif guess_age > age:
    10         print('Think smaller!')
    11     else:
    12         print('Think bigger!')
    13     count = count - 1  # count - =1也可以
    14     if count == 0:
    15         continue_guess = input('Do you want to countinue trying? Y or N
    ')
    16         if continue_guess == 'Y':
    17             count = 5
    18         else:
    19             print('Byebye')
    20 else:
    21     print('Game over!')
    22 '''改成for循环
    23 for n in range(5):
    24     print('您有{_count}次猜测机会!'.format(_count=count))
    25     guess_age = int(input('guess age:'))
    26     if guess_age == age:
    27         print('Yes,you got it.')
    28         break
    29     elif guess_age > age:
    30         print('Think smaller!')
    31     else:
    32         print('Think bigger!')
    33     count = count - 1
    34 else:print('Game over!')
    35 '''
  • 相关阅读:
    Beans
    Redis记录-Redis命令
    Redis记录-Redis介绍
    RESTful记录-RESTful服务
    RESTful记录-RESTful内容
    RESTful记录-RESTful介绍
    HTTP记录-HTTP介绍
    Solr记录-solr检索和查询数据
    Solr记录-solr文档xml
    Solr记录-solr内核与索引
  • 原文地址:https://www.cnblogs.com/gzj137070928/p/13752970.html
Copyright © 2011-2022 走看看