1.T or F 1>1 or 3<4 or 4>5 and 2>1 and 9>8 or 7<6 t not 2>1 and 3<4 or 4>5 and 2>1 and 9>8 or 7<6 f 2.值 8 or 3 and 4 or 2 and 0 or 9 and 7 8 0 or 2 and 3 and 4 or 6 and 0 or 3 4 3.结果 6 or 2>1 #6 3 or 2>1 #3 0 or 5<4 #F 5<4 or 3 #3 2>1 or 6 #T 3 and 2>1 #T 0 and 3>1 #0 2>1 and 3 #3 3>1 and 0 #0 3>1 and 2 or 2<3 and 3 and 4 or 3>2 #t and 2 or t and 3 and 4 or t=2 or 4 or t=2 or t=2 4.while 循环语句基本结构 while 条件: 循环体(代码块) else: 条件为假 5.猜大小 while True: a = int(input("输入数字:")) if a>66: print("大") elif a<66: print("小") else: print("正确") break 6.3次机会 n = 3 while n>0: a = int(input("输入数字:")) if a>66: print("大") elif a<66: print("小") else: print("正确") break n-=1 print("剩余机会:%d次" % n) else: print("太笨了") 7.输出1 2 3 4 5 6 8 9 10 (1)n = 1 while n<11: if n==7: n+=1 continue print(n) n+=1 (2)n = 1 while n<11: if n != 7: print(n) n+=1 8.1-100和 n = 1 s = 0 while n<=100: s = s + n n+=1 print(s) 9.1-100奇数 n = 1 while n<=100: if n%2 == 0: n+=1 continue else: print(n) n+=1 10.1-100偶数 n = 1 while n<=100: if n%2 == 1: n+=1 continue else: print(n) n+=1 11.1-2+3-4+5..99的和 (1)n = 1 a = 0 while n <= 99: a = a + n n+=2 n = 2 b = 0 while n <= 99: b = b + n n += 2 print(a-b) (2)n = 1 s = 0 while n < 100: if n%2 == 0: s = s - n else: s = s + n n+=1 print(s) 12.3次登录,剩余次数 c = 1 while c <= 3: name = input("用户名:") pw = input("密码:") if name == "zjx" and pw == "123": print("登录成功!") break else: print("登录失败!") print("剩余次数:%s" % (3 - c)) c += 1 else: print("登录错误") 13.过敏词汇 num = input("请输入广告词汇:") if ("最" or "第一" or "国家" or "稀缺") in num: print("过敏词汇!") else: print("正确!")