Reputation: 33
With following condition, what should Python return? In which sequence the condition will get executed?
True or False and False and True
Upvotes: 3
Views: 182
Reputation: 354
Like @Dean Dumitru has said and like it said in this answer here; the AND has a higher precedence than OR.
Hence, your condition could be rewritten in this way:
True or ((False and False) and True) -> True or (False and True) -> True or False -> TRUE
Upvotes: 1
Reputation: 39
AND has a higher precedence than OR.
True or False and False and True -> True or TRUE and True -> True or TRUE -> TRUE.
http://www.mathcs.emory.edu/~valerie/courses/fall10/155/resources/op_precedence.html
Upvotes: 3