## 使用while循环输入 1、2、3、4、5、6、8、9、10

方法一:

1 n = 1
2 while n < 11:
3     if n == 7:
4         pass
5     else:
6         print(n)
7     n += 1

方法二:

1 a = 0
2 n = 1 
3 while a < 10:
4     if n == 7:
5         pass
6     else:
7         print(n)
8     n += 1
9     a += 1

##输出1-100内的所有数

1 n = 1
2 while n < 101:
3     print(n)
4     n += 1

##输出1-100内的所有奇数

1 n = 1
2 while n < 101:
3     temp = n % 2 
4     if temp == 0:
5         pass
6     else:
7         print(n)
8     n += 1

##输出1-100内的所有偶数

1 n = 1
2 while n < 101:
3     temp = n % 2 
4     if temp == 0:
5         print(n)
6     else:
7         pass
8     n += 1

##求1-100的所有数的和

1 n = 1
2 sum = 0
3 while n <101:
4 ##    print(n)
5     sum = sum + n
6     n += 1
7 print(sum)

##求1-2+3-4+5.。。。99的所有数的和

1 n = 1
 2 sum = 0
 3 while n < 100:
 4     temp = n % 2
 5     if temp == 0:
 6         sum = sum - n
 7     else:
 8         sum = sum + n
 9     n += 1
10 print(sum)