第6课课后题我不懂的有:
一、请用最快速度说出答案:not 1 or 0 and 1 or 3 and 4 or 5 and 6 or 7 and 8 and 9
这题我一看就傻掉了。。。(⊙_⊙)
这视频教学里没讲啊,我就上网搜,结合自己实践举例,得出做题思路。
解答:
1、搜到:当not和and及or在一起运算时,优先级为是not>and>or
2、实践关于not:
>>> not 1
False
>>> not 0
True
>>> not1
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
not1
NameError: name 'not1' is not defined
#所以输入not、and、or的时候要加空格,要不然会报错!
3、实践关于and:
>>> 3 and 7
7
>>> 7 and 3
3
#说明and取最后一个数字,不论数字大小,我之前还以为是加法呢,哈哈~
4、实践关于or:
>>> 2