2017-10-10 157 views
0

我在布爾運算符的鍛鍊,我不明白爲什麼:布爾運算符鍛鍊

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

通常,and給出優先於or,所以你的表達等同於

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

優先級:

NOT > AND > OR 

因此

not not True or False and not True = True 

就像:

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