本节学习一些python中的基本逻辑。
符号 | 意义 |
---|---|
and | 与 |
or | 或 |
not | 非 |
!= | (not equal) 不等于 |
== | (equal) 等于 |
>= | (greater-than-equal) 大于等于 |
<= | (less-than-equal) 小于等于 |
True | 真 |
False | 假 |
下面是真值表:
表一、
NOT | TRUE? |
---|---|
not False | True |
not True | False |
表二、
OR | TRUE? |
---|---|
True or False | True |
True or True | True |
False or True | True |
False or False | False |
表三、
AND | TRUE? |
---|---|
True and False | False |
True and True | True |
False and True | False |
False and False | False |
表四、
NOT OR | TRUE? |
---|---|
not (True or False) | False |
not (True or True) | False |
not (False or True) | False |
not (False or False) | True |
表五、
NOT AND | TRUE? |
---|---|
not (True and False) | True |
not (True and True) | False |
not (False and True) | True |
not (False and False) | True |
表六、
!= | TRUE? |
---|---|
1 != 0 | True |
1 != 1 | False |
0 != 1 | True |
0 != 0 | False |
表七、
== | TRUE? |
---|---|
1 == 0 | False |
1 == 1 | True |
0 == 1 | False |
0 == 0 | True |