# 运算符5大类 # 算术运算符 % a = 1 b = 2 print(a + b) # 模运算 取余运算 a = 5 print(a % 3) # 判断奇偶 %2 # 赋值运算符 = += -= a = 6 # =是赋值运算 a += 2 # a=a+2 print(a) a -= 3 print(a) # 比较运算符 >、 >=、 < 、<=、 !=、 == # 比较结果返回的值是布尔值 True False a = 10 b = 5 print(a > b) print(a >= b) print(a < b) print(a != b) print(a == b) print("get" == "GET") print("get".upper() == "GET") print("get" == "GET".lower()) # 逻辑运算符 and or 拓展not # 逻辑运算返回值是布尔值 a = 10 b = 5 print(a > 11 and b > 6) print(a + b) print((a > 11) or (b > 4)) # 成员运算符 in 、not in # 返回值也是布尔值 s = "hello" print("o" in s) print("o" not in s) l = [1, 2, 3] print(l) print(1 in l) d = {"age": 18, "name": "鸭蛋"} print(d) print("age" in d) # 只能判断key,不能判断value