The Python Oracle

Python: How does python executes multiple boolean in one statement?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Lost Jungle Looping

--

Chapters
00:00 Python: How Does Python Executes Multiple Boolean In One Statement?
00:18 Answer 1 Score 3
00:33 Accepted Answer Score 1
00:48 Thank you

--

Full question
https://stackoverflow.com/questions/5244...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #booleanlogic

#avk47



ANSWER 1

Score 3


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




ACCEPTED ANSWER

Score 1


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