print(1 or 0 and 0) outputs 1. Is it correct to say that, with no parentheses, Python evaluates boolean expressions right-to-left?
5/30/2019 5:10:01 PM
Paolo De Nictolis3 Answers
New AnswerNo, it's not correct. Boolean AND has higher precedence than boolean OR. https://docs.python.org/3/reference/expressions.html#operator-precedence
Paolo De Nictolis hi, First 0 and 0 get evaluated which becomes 0 then (1 or 0) remains which evaluated 1 or 0 is evaluate and gives 1 so output comes as 1 Have some 🍎 🍎 🍎 🍎 🍎
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message