• while语句


    while 条件:

                     条件成立后执行代码

    1.打印1-100数字

    count=0

    while count <=100:

      print("loop",count)

      count+=1

    print("--------loop is ending----------")

    2.答应1-100的偶数

    count=0

    while count<=100

      if count % 2 ==0:

        print("loop",count)

      count+=1

    print("------loop is ending -------")

    3.打印1-100的数字,但是第50次的不打印,第60-80打印对应值的平方。

    伪代码:

    第一种情况:第50次不打印

    第二种情况:60-80次打印值的平方

    第三种情况:其他的正常打印

    count=0

    while count<=100

      if count==50:

        pass #过

      elif count>=60 and count<=80:

        print("count*count)

      else:

         print("loop",count)

  • 相关阅读:
    安卓学习57
    安卓学习56
    安卓学习55
    安卓学习54
    安卓学习53
    安卓学习52
    安卓学习51
    安卓学习50
    安卓学习49
    安卓学习48
  • 原文地址:https://www.cnblogs.com/chenjiao0904/p/9630612.html
Copyright © 2020-2023  润新知