Courseiva

PCEP Computer Programming and Python Fundamentals Practice Question

A developer wrote: a, b, c = 10, 20, 30; avg = a + b + c / 3; print(avg). What is the output?

⚠ Common exam trap

The PCEP exam often tests operator precedence by presenting an expression without parentheses, leading candidates to incorrectly assume left-to-right evaluation or to compute the average as `(a + b + c) / 3` instead of `a + b + (c / 3)`.

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

✓

40.0

Operator precedence in Python dictates that division (/) has higher precedence than addition (+). Therefore, the expression `a + b + c / 3` is evaluated as `a + b + (c / 3)`, which is `10 + 20 + (30 / 3) = 10 + 20 + 10.0 = 40.0`. The result is a float because division always returns a float in Python 3.

Answer analysis

Option-by-option breakdown

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

  • ✗

    60.0

    Why it's wrong here

    Python evaluates division before addition, so c / 3 yields 10.0 and the expression becomes 10 + 20 + 10.0, giving 40.0, not 60.0. It tempts because 60.0 is the sum of all three variables, which is the total, not the average.

  • ✗

    20.0

    Why it's wrong here

    Operator precedence evaluates `c / 3` first, giving 10.0, then adds a and b, so the printed value is 40.0, not 20.0. The 20.0 figure tempts because it is the true mean of 10, 20 and 30, which would result had the developer written `(a + b + c) / 3`.

  • ✓

    40.0

    Why this is correct

    Operator precedence makes division bind tighter than addition, so Python evaluates c / 3 as 30 / 3 = 10.0, then adds a + b, giving 10 + 20 + 10.0 = 40.0. The float result from true division explains the decimal output.

  • ✗

    30.0

    Why it's wrong here

    Operator precedence means only c is divided by 3, producing 10 + 20 + 10.0 = 40.0, so 30.0 never appears. It tempts because 30.0 is the value of c, and a reader may assume the average equals the final variable.

About these practice questions

One of 482 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.