nerdexam
Python_Institute

PCEP-30-02 · Question #97

Evaluate the following Python arithmetic expression: (3(1+2) 2-(22)3) What is the result?

The correct answer is D. 15. Option D (15) is correct because Python's operator precedence resolves the expression as follows: first, evaluate the parenthesized groups (1+2)=3 and (22)=4; then apply exponentiation 32=9 (since * binds tighter than `); then multiply 39=27 and 43=12; finally subtract to get…

Question

Evaluate the following Python arithmetic expression: (3*(1+2) 2-(22)*3) What is the result?

Options

  • A13
  • B3
  • C69
  • D15

How the community answered

(28 responses)
  • A
    14% (4)
  • B
    4% (1)
  • C
    7% (2)
  • D
    75% (21)

Explanation

Option D (15) is correct because Python's operator precedence resolves the expression as follows: first, evaluate the parenthesized groups (1+2)=3 and (2**2)=4; then apply exponentiation 3**2=9 (since ** binds tighter than *); then multiply 3*9=27 and 4*3=12; finally subtract to get 27-12=15.

Why the distractors fail:

  • C (69) is the most tempting wrong answer - it comes from misreading 3*(1+2)**2 as (3*(1+2))**2 = 9**2 = 81, then 81-12=69. The space before **2 is a visual trick; ** only applies to (1+2), not to the whole product.
  • A (13) likely results from arithmetic slips after incorrectly regrouping the expression.
  • B (3) likely comes from ignoring exponentiation or treating ** as repeated multiplication applied in the wrong order.

Memory tip: Remember "Please Excuse My Dear Aunt Sally" - but in Python, give extra weight to ** (Exponentiation), which always wins over * and -. When you see x * y**z, Python computes y**z first, then multiplies by x. A space between y and **z does not change this precedence.

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice