布尔运算符运算

时间:2017-10-10 20:25:24

标签: boolean operators

我正在练习布尔运算符,我不明白为什么:

not not True or False and not True = True

我理解:

not not True = True
True or False = False
False and not True = False

not not True or False and not True = False

2 个答案:

答案 0 :(得分:2)

通常,and的优先级高于or,因此您的表达式等同于

(not not True) or (False and not True) == True or (False and False)
                                       == True or False
                                       == True

答案 1 :(得分:0)

优先顺序:

NOT >  AND > OR

因此

not not True or False and not True = True

就像:

2 + 3 * 3 - 1 = 10 and not 14.