• while/for循环+if猜年龄


    初学python,贴一段代码!
    1. 先来个猜年龄的玩法

     1 _oldboy_age = 56
     2 count = 0
     3 while count <3:
     4     guess_age = int(input("guess_age:"))
     5     if guess_age == _oldboy_age:
     6        print("yes ,you right!")
     7        break
     8     elif guess_age > _oldboy_age:
     9           print("think smaller")
    10     else:
    11            print("think bigger")
    12 
    13     count +=1
    14     if count == 3:
    15         confirm = input("Do want to keep guessing?")
    16         if confirm != 'n':
    17             count = 0
    18 
    19 
    20 else:
    21 
    22     print("you have try too much times,get off!")
     1 _oldboy_age = 56
     2 
     3 for a in range(3):
     4     guess_age = int(input("guess_age:"))
     5     if guess_age == _oldboy_age:
     6        print("yes ,you right!")
     7        break
     8     elif guess_age > _oldboy_age:
     9           print("think smaller")
    10     else:
    11         print("think bigger")
    12 
    13 else:
    14 
    15     print("you have try too much times,get off!")
  • 相关阅读:
    父类与子类之间的调用顺序
    ROW_NUMBER() OVER函数的基本用法用法
    String类
    代码块
    权限修饰符
    内部类
    final&static
    面向对象思想
    oracle存储过程常用技巧
    ORACLE EXECUTE IMMEDIATE 用法
  • 原文地址:https://www.cnblogs.com/szchenh2010/p/7638035.html
Copyright © 2020-2023  润新知