zoukankan      html  css  js  c++  java
  • python-day6---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







    # 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




    补充:
    while True:
    name=input('please input your name: ')
    password=input('please input your password: ')

    if name == 'egon' and password == '123':
    print('login successfull')
    while True:
    cmd=input('>>: ')
    if cmd == 'quit':
    break
    print('====>',cmd)
    break


    tag=True
    while tag:
    name=input('please input your name: ')
    password=input('please input your password: ')

    if name == 'egon' and password == '123':
    print('login successfull')
    while tag:
    cmd=input('>>: ')
    # if cmd == 'quit':
    # tag=False
    # continue
    # print('====>',cmd)

    if cmd == 'quit':
    tag=False
    else:
    print('====>',cmd)



    count=0
    while count < 10:
    if count == 3:
    count+=1
    continue
    print(count)

    count+=1
    else: #最后执行
    print('在最后执行,并且只有在while循环没有被break打断的情况下才执行')


    优化:
    ount=0
    while count < 10:
    if count == 3:
    pass
    else:
    print(count)
    count+=1
  • 相关阅读:
    java实现简单web服务器(分析+源代码)
    Java中常见的5种WEB服务器介绍
    Android ViewDragHelper完全解析 自定义ViewGroup神器
    设置SVN,Git忽略MAC的.DS_Store文件的方法
    Android中图片大小和屏幕密度的关系讲解
    Android组件化方案及组件消息总线modular-event实战
    机器学习在美团配送系统的实践:用技术还原真实世界
    智能支付稳定性测试实战
    数据库智能运维探索与实践
    【人物志】技术十年:美团第一位前端工程师潘魏增
  • 原文地址:https://www.cnblogs.com/liuwei0824/p/7200717.html
Copyright © 2011-2022 走看看