while count <= 10 :
if n == 7 : #冒号不要忘记
1 #使用while循环输出 1 2 3 4 5 6 8 9 10 2 n = 1 3 while n < 11: 4 if n == 7: 5 pass 6 else : 7 print(n) 8 n = n + 1 9 print('----end----')
1 #1.输出100以内的所有偶数 2 """ 3 #自己代码 4 count = 0 5 while count < 101: 6 7 count = count + 1 8 if count % 2 == 0: 9 print (count) 10 11 12 #teacher's 13 n = 1 14 while n < 101: 15 temp = n % 2 16 if temp == 0: 17 print(n) 18 else: 19 pass 20 n = n + 1 21 print ('----end----') 22 """ 23 #4.输出1到100所有的和 24 """ 25 n = 1 26 s = 0 27 while n < 101: 28 print(n) 29 s = s + n 30 n = n + 1 31 print (s) 32 """ 33 34 35 #5.求 1-2+3_4+5...99所有数的和 36 #teacher's 37 """ 38 n = 1 39 s = 0 40 41 while n < 100 42 temp = n % 2 43 if temp == 0 : 44 s = s - n 45 else: 46 s = s + n 47 n = n + 1 48 print (s) 49 50 #自己 51 n = 1 52 s = 0 53 while n < 101: 54 print(n) 55 if n % 2 == 0 56 n = n * -1 57 s = s + n 58 n = n + 1 59 60 print (s) 61 """View Code