# 1、使用while循环输入 1 2 3 4 5 6 8 9 10 ‘‘‘ count=1 while count<=10: if count==7: print( ) count=count+1 continue print(count) count=count+1 ‘‘‘ # 2、求1-100的所有数的和 ‘‘‘ sum=0 count=1 while count<=100: sum=sum+count count=count+1 print(sum) ‘‘‘ # 3、输出 1-100 内的所有奇数 ‘‘‘ odd=1 while odd<=100: if odd % 2==0: odd=odd+1 continue print(odd) odd=odd+1 ‘‘‘ ‘‘‘ odd=1 while odd<=100: if odd%2==1: print(odd) odd=odd+1 ‘‘‘ # 4、输出 1-100 内的所有偶数 ‘‘‘ even=1 while even<=100: if even%2==1: even=even+1 continue print(even) even=even+1 ‘‘‘ ‘‘‘ even=1 while even<=100: if even%2==0: print(even) even=even+1 ‘‘‘ # 5、求1-2+3-4+5 ... 99的所有数的和 ‘‘‘ sum=1 count=2 while count<=99: sum=sum-count count=count+1 sum=sum+count count=count+1 print(sum) ‘‘‘ # 6、用户登陆(三次机会重试) ‘‘‘ username="ABC" password="123" i=1 while i<=3: name=input(‘请输入账号:‘) word=input(‘请输入密码:‘) if name==‘ABC‘ and word==‘123‘: print(‘登录成功‘) break elif i<=2: print(‘登录失败,还有‘+str(3-i)+‘次机会‘) i=i+1 continue else : print(‘登陆失败,不能登录‘) break ‘‘‘ ‘‘‘ username="ABC" password="123" i=1 while i<=3: name=input(‘请输入账号:‘) word=input(‘请输入密码:‘) if name==‘ABC‘ and word==‘123‘: print(‘登录成功‘) break elif i==3: print(‘登陆失败,不能登录‘) break print(‘登录失败,还有‘+str(3-i)+‘次机会‘) i=i+1 ‘‘‘