Skip to content

Latest commit

 

History

History
85 lines (63 loc) · 2.15 KB

ex27.md

File metadata and controls

85 lines (63 loc) · 2.15 KB

逻辑术语

在 python 中我们会用到下面的术语(字符或者词汇)来定义事物的真(True)或者假(False)。计算机的逻辑就是在程序的某个位置检查这些字符或者变量组合在一起表达的结果是真是假。

逻辑词 含义
and
or
not
!=(not equal) 不等于
==(equal) 等于
>=(greater-than-equal) 大于等于
<=(less-than-equal) 小于等于
True
False

真值表

01 非假即真,非真即假

NOT TRUE
not False True
not True False

02 全真则真,全假则假,其他看情况

OR TRUE?
True or False True
True or True True
False or True True
False or False False

03 有假则假,全真则真

AND TRUE?
True and False False
True and True True
False and True False
False and False False

04 全假则真,其他全假

NOT OR TRUE?
not (True or False) False
not (True or True) False
not (False or True) False
not (False or False) True

05 全真则假,其他全真

NOT AND TRUE?
not (True and False) True
not (True and True) False
not (False and True) True
not (False and False) True

06

!= TRUE?
1 != 0 True
1 != 1 False
0 != 1 True
0 != 0 False

07

== TRUE?
1 == 0 False
1 == 1 True
0 == 1 False
0 == 0 True

更多运算符

Python运算符总结