# 1、使用while循环输入 1 2 3 4 5 6 8 9 10 count = 0 while count < 10: count += 1 if count == 7: continue print(count) # 2、求1 - 100的所有数的和 sum = 0 x = 1 while x < 101: sum = sum + x x +=1 print(sum) # 3、输出 1-100 内的所有奇数 odd = 0 while odd < 100: odd += 1 if odd % 2 == 1: print(odd) # 4、输出 1-100 内的所有偶数 even = 0 while even < 100: even += 1 if even % 2 == 0: print(even) # 5、求1-2+3-4+5 ... 99的所有数的和 num = 1 sum = 0 while num < 100: if num % 2 == 1: sum = sum + num elif num % 2 == 0: sum = sum - num num += 1 print(sum) # 6、用户登陆(三次机会重试) count = 0 while count < 3: count += 1 user = input("请输入用户名") passWord = input("请输入密码") if user == "evic" and passWord == "123": print("Welcome") elif count > 2: print("go away") else: print(‘please try again‘)