Explanation:
๐ง 1. Operator Precedence (Priority Rules)
In Python, logical operators follow this order:
and → evaluated first
or → evaluated after
So the expression is treated as:
0 or (5 and 3)
⚙️ 2. Evaluating 5 and 3
and returns the first falsy value, or the last value if all are truthy
Here:
5 → truthy
3 → truthy
So:
5 and 3 → 3
⚙️ 3. Evaluating 0 or 3
or returns the first truthy value
Here:
0 → falsy
3 → truthy
So:
0 or 3 → 3
✅ 4. Final Result
print(3)
Final Output:
3

0 Comments:
Post a Comment