再学习了这三个逻辑判断后,做了一个小测验。
print(3 == 3 and not ("testing" == "testing" or "Python" == "Fun"))
'''
逻辑优先级()>not>and>or
1.先判断小括号or见一得一,所以输出testing=testing 为T
2.判断not,则为not T(testing=testing),输出为F
3.判断and,必须全部对才能输出为T,否则为F
4.最后结果为F
'''
print(1 == 1 and not ("testing" == 1 or 1 == 0))
'''
逻辑优先级()>not>and>or
1.先判断小括号or,两边都不相等,则为F
2.判断not,not F(两边不相等),输出T
3.判断and,两边都为对的,则输出最后的命令为T
'''
print(not ("testing" == "testing" and "Zed" == "Cool Guy"))
'''
逻辑优先级()>not>and>or
1.先判断括号里的and,后面的一个公式不恒等,输出为F
2.not F(公式不相等),取反输出T
'''
print(3 and 4 and 5)
'''
and逻辑中,全部都是对的,则取最后输出的数字,则输出为5。
'''
print(5 and 6 or 7)
'''
这个公式先考虑or,再考虑and
1.逻辑or中直接输出6
'''
print(4 > 3 and print('hello world'))
print(5 and print('hello world'))
print(4 > 3 and print('7'))
print(6 and print('7'))
'''
1.按顺序判断
2.4>3 输出为T
3.打印“hello world”
4.通过以下实验,这两个公式之间没有逻辑,不能判断
'''
因为只学了这三个其他的还不会,大佬如果还有一些关于这三个逻辑的东西,也可以教教我。



