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)

原文地址:https://www.cnblogs.com/chenjiao0904/p/9630612.html