python中not5的值_自学Python教程【第五十二节】真值表

欢迎大家来到马哥

逻辑判断是编程中极为常用的知识。之前的课我们已经说过,见第4课和第9课。但鉴于逻辑运算的重要性,今天我再把常用的运算结果总结一下,供大家参考。

这种被称为“真值表”的东西,罗列了基本逻辑运算的结果。你不一定要全背下来,但应该对运算的规律有所了解。

为了便于看清,我用<=>来表示等价关系。

<=>左边表示逻辑表达式,<=>右边表示它的结果。

NOT

not False <=> True

not True <=> False

(not的结果与原值相反)

OR

True or False <=> True

True or True <=> True

False or True <=> True

False or False <=> False

(只要有一个值为True,or的结果就是True)

AND

True and False <=> False

True and True <=> True

False and True <=> False

False and False <=> False

(只要有一个值为False,or的结果就是False)

NOT OR

not (True or False) <=> False

not (True or True) <=> False

not (False or True) <=> False

not (False or False) <=> True

NOT AND

not (True and False) <=> True

not (True and True) <=> False

not (False and True) <=> True

not (False and False) <=> True

!=

1 != 0 <=> True

1 != 1 <=> False

0 != 1 <=> True

0 != 0 <=> False

==

1 == 0 <=> False

1 == 1 <=> True

0 == 1 <=> False

0 == 0 <=> True

以上就是基本的逻辑运算,你会在编程中反复用到它们。就算刚开始搞不清也没关系,多写几段代码就会熟悉了。

恭喜你在

好啦,今天的分享到这里就结束了,希望大家能够持续关注马哥教育官网,每天都会有大量优质内容与大家分享

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值