zoukankan      html  css  js  c++  java
  • python_8_guess

    #python3和2都可以
    #方法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('yes,you got it.')
            break#结束整个循环
        elif guess_age>age_of_oldboy:
            print('think smaller...')
        else:
            print("think bigger!")
        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('yes,you got it.')
            break#结束整个循环
        elif guess_age>age_of_oldboy:
            print('think smaller...')
        else:
            print("think bigger!")
        count+=1
    if count==3:
        print('you have tried too many times,fuck off')
    
    #方法3
    age_of_oldboy=56
    count=0
    while count<3:
        guess_age=int(input('guess age:'))
        if guess_age==age_of_oldboy:
            print('yes,you got it.')
            break#结束整个循环
        elif guess_age>age_of_oldboy:
            print('think smaller...')
        else:
            print("think bigger!")
        count+=1
    else:
        print('you have tried too many times,fuck off')
    
    
    #python2是可运行的,不需要转换成整数
    age_of_oldboy=56
    
    guess_age=input('guess age:')
    if guess_age==age_of_oldboy:
        print('yes,you got it.')
    elif guess_age>age_of_oldboy:
        print('think smaller...')
    else:
        print("think bigger!")
    

      

  • 相关阅读:
    BIOS中的UEFI和Legacy启动模式
    php和java中的加密和解密
    Linux 的进程状态
    C++继承:公有,私有,保护
    编译器在构造函数里都做了些什么?
    操作符重载
    C++对象模型学习笔记
    sizeof操作符-结构体与类大小
    C++之智能指针
    C/C++笔试题整理
  • 原文地址:https://www.cnblogs.com/tianqizhi/p/8182162.html
Copyright © 2011-2022 走看看