1.使用while循环输入 1 2 3 4 5 6 8 9 10
#使用while循环输出1 2 3 4 5 6 8 9 10 i=1 while i<=10: if i!=7: print(i) else: print(' ') i=i+1 print('----end----')
或者
i=1 while i<11: if i==7: pass else: print(i) i=i+1 print('----end----')
2.求1-100的所有数的和
#求1-100的所有数的和 i=1 s=0 while i<101: s=s+i i=i+1 print('s=1+2+3+...+100=',s)