>[success] # 运算符 ~~~ 1.算术运算符 2.比较运算符 3.赋值运算符 4.逻辑运算符 5.优先级,()> not > and > or ~~~ >[danger] ##### 算术运算符 ~~~ 1.以下假设变量:a=10,b=20 ~~~ ![](https://box.kancloud.cn/961ff069b6f62d3521f03ae005c3e6f7_763x236.png) >[danger] ##### 比较运算符 ~~~ 1.以下假设变量:a=10,b=20 ~~~ ![](https://box.kancloud.cn/ef24eaf3fc246b563764158f9e860994_775x276.png) >[danger] ##### 赋值运算符 ~~~ 1.以下假设变量:a=10,b=20 ~~~ ![](https://box.kancloud.cn/b9700a0c1276f352e36bac865e53f23d_769x273.png) >[danger] ##### 逻辑运算符 ~~~ 1.优先级,()> not > and > or 2.如果是数字形式 x or y , x为真,值就是x,x为假,值是y; x and y, x为真,值是y,x为假,值是x。 3.OR,相当于将两个触点并联;只要有一个就能走通 AND,相当于将两个触点串联;两个都走才能通 ~~~ ![](https://box.kancloud.cn/084be089e99c1314b87c531e9391750f_767x114.png) >[danger] ##### 案例 ~~~ 1.当单个数字的时候,会打印出数字结果 2.优先级,()> not > and > or ~~~ ~~~ print(2 or 1 < 3) print(3 > 1 or 2 and 2) 打印结果: 2 True ~~~ * 案例二 ~~~ print(3>4 or 4<3 and 1==1) # F print(1 < 2 and 3 < 4 or 1>2) # T print(2 > 1 and 3 < 4 or 4 > 5 and 2 < 1) # T print(1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8) # F print(1 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # F print(not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # F 打印结果: False True True False False False ~~~