1 # 使用while 循环输入 1 2 3 4 5 6 8 9 10 2 n = 1 3 while n <= 10: 4 if n == 7: 5 pass 6 else: 7 print(n) 8 n = n + 1 9 10 # 求1-100的所有数的和 11 n = 1 12 count = 0 13 while n <= 100: 14 count = count + n 15 n = n + 1 16 print(count) 17 18 # 输出1-100 内的所有奇数 19 n = 1 20 while n <= 100: 21 if n % 2 == 1: 22 print(n) 23 n = n + 1 24 25 # 输出1-100 内的所有偶数 26 n = 1 27 while n <= 100: 28 if n % 2 == 0: 29 print(n) 30 n = n + 1 31 32 # 求 1-2+3-4+5...99的所有数的和 33 n = 1 34 count = 0 35 while n <= 99: 36 if n % 2 == 1: 37 count = count + n 38 elif n % 2 == 0: 39 count = count - n 40 n = n + 1 41 print(count)