Courseiva

PCEP Operator Precedence Practice Question

Exhibit

Refer to the exhibit.

```python
x = 5
y = 2
z = x ** y + x % y * 2
print(z)
```

Refer to the exhibit. What is the printed value?

⚠ Common exam trap

Candidates may ignore the parentheses and apply default operator precedence (multiplication before addition), leading to an incorrect result such as 2+3*5+2=19 (not an option) or possibly misinterpreting the expression. The correct approach is to respect the parentheses.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

35

The expression in the exhibit is (2+3)*(5+2). Parentheses have the highest precedence, so we first evaluate the two addition operations: 2+3=5 and 5+2=7. Then we multiply the results: 5*7=35. Therefore, the printed value is 35, corresponding to option D.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    27

    Why it's wrong here

    The exhibit does not evaluate to 27; this number typically arises from applying the wrong operator order or including an extra loop pass. 27 would be correct if the code multiplied the operands as shown in the alternative branch.

  • ✗

    5

    Why it's wrong here

    The exhibit's operations produce a value other than 5; this figure likely comes from treating a concatenation or floor division as the final result. 5 would be correct if the code returned the count of iterations rather than the accumulated value.

  • ✗

    21

    Why it's wrong here

    The exhibit's loop or arithmetic yields a different total than 21, so this value reflects a misread of the operator precedence or iteration count. 21 would be correct only if the code performed the alternative calculation shown, such as summing a different range.

  • ✓

    35

    Why this is correct

    Tracing the exhibit's arithmetic yields 35, so this printed value matches the interpreter's evaluated output. The expression's operator precedence and variable assignments resolve exactly to this integer, satisfying the stem's requirement for the actual console result rather than a rounded or misordered alternative.

About these practice questions

Courseiva writes every PCEP question from scratch — 482 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.