while循环作业

1.打印1 2 3 4 5 6 8 9 10

#!/usr/bin/python

count = 0

while count < 11:

       count = count + 1    

  if count == 7:

    continue    

       print count

2.计算1..100的和

#!/usr/bin/python

count = 0 

sum = 0 

while count < 100:

  count = count + 1

       sum = sum + count

       print sum

3. 计算1.. 100 的偶数和

#!/usr/bin/python

count = 0 

sum = 0 

while count < 100:

  tmp = count  % 2

  if tmp == 0: 

         sum = sum + count

  count = count + 1       

  print sum  

 

posted on 2018-08-25 10:12  *-帝释天-*  阅读(107)  评论(0编辑  收藏  举报