Which of the following is the correct precedence of operators in Python?

2023

Which of the following is the correct precedence of operators in Python?

  1. A.

    Braces, or, and, not

  2. B.

    not, Braces, and, or

  3. C.

    not, Braces, or, and

  4. D.

    Braces, not, and, or

Attempted by 1967 students.

Show answer & explanation

Correct answer: D

Key point: Operator precedence from highest to lowest: parentheses (braces) → not → and → or. parentheses (braces): group expressions and are evaluated first.

not: unary logical negation, evaluated after parentheses.

and: logical conjunction, evaluated after 'not'.

or: logical disjunction, lowest precedence among these operators.

Example: Evaluate the expression step by step: Start: not False and False or True

Step 1 (not): not False

Explore the full course: Rssb Senior Computer Instructor