python-练习1
#1.while使用while循环输入1 2 3 4 5 6 8 9 10 '''count = 0 while count<10: count += 1 if count == 7: continue else: print(count)''' #2.while求1-100的和 '''count=1 sum=0 while count<101: sum+=count count+=1 print(sum)''' #3.输出1-100内所有的奇数 #方法一: '''count=1 while count<101: print(count) count+=2''' #方法二: '''count=1 while count<101: if count%2 == 1: print(count) count+=1''' #4.输出1-100内所有偶数与上面方法相同 #5.求1-2+3-4+5...99的所有数的和 '''count=1 sum=0 while count<100: if count%2==1: sum+=count else: sum-=count count+=1 print(sum)''' #6.用户登陆(三次机会重试) '''i=0 while i<3: username=input("请输入账号:") password=input("请输入密码:") if username=='orange' and password=='123': print('登陆成功') break else: if i != 2: print('登陆失败还有'+str(2-i)+'次机会') else: print('登陆失败') i+=1'''