zoukankan      html  css  js  c++  java
  • while循环

    # while 条件:
    # 循环体的代码1
    # 循环体的代码2
    # 循环体的代码3
    # count=0
    # while count < 10:
    # print(count)
    # count+=1


    # while True: #死循环
    # print('ok')

    # while 1: #死循环
    # print('ok')



    #break:跳出本层循环
    # count=0
    # while count < 10:
    # if count == 5:
    # break
    # print(count)
    # count+=1

    #continue:跳出本次循环
    #0 1 2 3 7 8 9


    # count=0
    # while count < 10:
    # if count >=4 and count <=6:
    # count += 1
    # continue
    # print(count)
    # count+=1


    # OLDBOY_AGE=56
    # while 1:
    # age=input('猜一猜年龄>>: ')
    # age=int(age)
    #
    # if age > OLDBOY_AGE:
    # print('太大了')
    # elif age < OLDBOY_AGE:
    # print('太小了')
    # else:
    # print('猜对了')
    # break



    # OLDBOY_AGE=56
    # count=1
    # while count <= 3:
    # age=input('猜一猜年龄>>: ')
    # age=int(age)
    #
    # if age > OLDBOY_AGE:
    # print('太大了')
    # count+=1
    # elif age < OLDBOY_AGE:
    # print('太小了')
    # count+=1
    # else:
    # print('猜对了')
    # break





    OLDBOY_AGE=56
    count=1
    while True:
    if count > 3:
    print('您猜的次数超过限制')
    break
    age=input('猜一猜年龄>>: ')
    age=int(age)

    if age > OLDBOY_AGE:
    print('太大了')
    elif age < OLDBOY_AGE:
    print('太小了')
    else:
    print('猜对了')
    break
    count += 1






    # OLDBOY_AGE=56
    # while True:
    # score = input('>>: ')
    # score = int(score)
    #
    # if score >= 90:
    # print('A')
    # if score >= 80:
    # print('B')
    # if score >= 70:
    # print('C')
    # if score >= 60:
    # print('D')
    # if score < 60:
    # print('E')







    OLDBOY_AGE=56
    count=0
    while True:
    if count > 2:
    break
    age=input('猜一猜年龄>>: ')
    age=int(age)
    if age > OLDBOY_AGE:
    print('太大了')

    if age < OLDBOY_AGE:
    print('太小了')

    if age == OLDBOY_AGE:
    print('猜对了')
    break
    count += 1
  • 相关阅读:
    python3爬虫-快速入门-爬取图片和标题
    数据库Mysql的学习(八)-储存过程和事务和导入导出
    数据库Mysql的学习(七)-自定义函数和流程控制
    git reset --hard HEAD^
    list采坑记录一下
    Linux运行jar包
    JSONObject.toJSONString(map)
    String转list
    判断list中元素是否是相邻
    统计List中相同的元素
  • 原文地址:https://www.cnblogs.com/0704L/p/7201290.html
Copyright © 2011-2022 走看看