Operator precedence determines the order in which parts of an expression are evaluated. In Python, it matters when a conditional combines arithmetic, comparisons, membership checks, and Boolean operators such as and and or. section 14.1
A condition that looks similar but behaves differently
Correct: if num_a < 0 and num_b < 0: print("both negative")\nIncorrect: if num_a and num_b < 0: print("both negative")\n\nThe first condition checks whether both values are less than zero. The second does not repeat the comparison for num_a, so it can print "both negative" when num_a is 1 and num_b is -1. Quick checks include 3 < 2 ** 3 and 3 == 3, and expressions combining or, and, membership, and len(). section 14.1
When an expression feels unclear, add parentheses, work through each operation in order, and test the result instead of relying on appearance alone. section 14.3






