Courseiva

PCEP Practice Question: Data Types, Variables, Basic I/O and Operators

A developer writes a program to calculate the average of three numbers: a=10; b=20; c=30; avg = a + b + c / 3; print(avg). What is the output?

⚠ Common exam trap

Python Institute often tests operator precedence by placing a division operation at the end of an expression without parentheses, tricking candidates into assuming left-to-right evaluation or that the entire sum is divided.

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

The expression `a + b + c / 3` follows Python's operator precedence: division (`/`) has higher precedence than addition (`+`), so `c / 3` is evaluated first (30 / 3 = 10.0), then the additions are performed left to right: 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.

  • ✗

    20.0

    Why it's wrong here

    Operator precedence evaluates c / 3 first, giving 10.0, then adds a and b, so the result is 40.0, not 20.0. This value would appear only if the sum were divided correctly, which the missing parentheses prevent.

  • ✗

    10.0

    Why it's wrong here

    Python evaluates division before addition, so c/3 yields 10.0 and the sum becomes 40.0, not 10.0. The option is tempting because 10.0 is the value of c/3 alone, which is what you get if you wrongly assume the expression groups as a+b+c divided by 3.

  • ✓

    40.0

    Why this is correct

    Operator precedence evaluates division before addition, so c / 3 yields 10.0, then a + b + 10.0 gives 40.0. The float result arises because true division always returns a float in Python 3, satisfying the stem's expression exactly as written without parentheses.

  • ✗

    60.0

    Why it's wrong here

    The expression evaluates as 10 + 20 + (30 / 3), since division binds tighter than addition, giving 40.0, not 60.0. This value would appear only if the sum were parenthesised as (a + b + c) / 3, which is the intended average calculation the developer failed to write.

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.