Which of the following correctly shows the usual precedence order in Python?

2026

Which of the following correctly shows the usual precedence order in Python?

  1. A.

    **, (), (*, /), (+, -)

  2. B.

    (), **, (+, -), (*, /)

  3. C.

    **, (), (/, *), (+, -)

  4. D.

    (), **, (*, /), (+, -)

Attempted by 228 students.

Show answer & explanation

Correct answer: D

In Python, grouping with parentheses is evaluated first, followed by exponentiation **. Multiplication and division have the same precedence level, and addition and subtraction also share a lower precedence level. Therefore the correct order is: (), **, (*, /), (+, -). Operators in the same precedence level are grouped together, so the order between * and / is not a separate precedence difference.

Explore the full course: Rssb Senior Computer Instructor