• While循环


    1.

    age_of_oldboy = 56
    
    count = 0
    while True:
        if count == 3:
            break
        guess_age =int(input ("guess age:"))
        if guess_age == age_of_oldboy:
            print ("you got it")
            break
        elif guess_age > age_of_oldboy:
            print("think bigger!!!")
        else:
            print("think smaller!!")
        count +=1

    2

    age_of_oldboy = 56
    
    count = 0
    while count < 3:
        guess_age =int(input ("guess age:"))
        if guess_age == age_of_oldboy:
            print ("you got it")
            break
        elif guess_age > age_of_oldboy:
            print("think bigger!!!")
        else:
            print("think smaller!!")
        count +=1
    else:
         print("you have tried many times...")

     3

    age_of_oldboy = 56
    count = 0
    while count < 3:
        guess_age =int(input ("guess age:"))
        if guess_age == age_of_oldboy:
            print ("you got it")
            break
        elif guess_age > age_of_oldboy:
            print("think bigger!!!")
        else:
            print("think smaller!!")
        count +=1
        if count == 3:
            continue_confirm = input ("Do you want to cntinue keep trying..?")
            if continue_confirm != "n":
                count = 0
  • 相关阅读:
    需要我们了解的SQL Server阻塞原因与解决方法
    SQL Server应用模式之OLTP系统性能分析
    第一章 scala环境搭建
    IO
    装饰器模式
    java 泛型方法
    文件格式转换
    spring ioc
    深入浅出Java模式设计之模板方法模式
    struts2
  • 原文地址:https://www.cnblogs.com/wz123/p/9652156.html
Copyright © 2020-2023  润新知