+ 1
Boolean priority?
Why is this output True? Does the Boolean āandā have a priority over āorā? What am I not understanding? print(True or True and False) Output: True How I attempted to solve was by taking it apart from left to right. True or True = (True) (True) and False = False End result is False. Which is what I thought.
2 Answers
+ 5
As OP have not mentioned any language, I am assuming it to be python and if that's the case then
Yes, logical AND have higher precedence than OR, meaning the expression would be evaluated like this
print ( True or ( True and False ))
Which will always result in True
Check the following docs to know more about operator precedence in pythonš
https://docs.python.org/3/reference/expressions.html#operator-precedence
+ 2
Yes, it was a python question! Thank you for the clarification.