Courseiva

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

A developer writes a script to calculate the average of three numbers: avg = (a + b + c) / 3. If a=5, b=10, c=15, what is the data type of avg?

⚠ Common exam trap

Python Institute often tests the distinction between / (true division, returns float) and // (floor division, returns int) to trap candidates who assume integer division returns an integer.

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

✓

float

In Python, the division operator (/) always returns a float, even when dividing integers that result in a whole number. Here, (5 + 10 + 15) / 3 equals 30 / 3, which yields 10.0, a float. Therefore, the data type of avg is float.

Answer analysis

Option-by-option breakdown

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

  • ✓

    float

    Why this is correct

    Division with `/` in Python always yields a float, even when the operands are integers and divide evenly. Here (5 + 10 + 15) / 3 evaluates to 30 / 3, producing 10.0 rather than the integer 10, so avg is a float.

  • ✗

    bool

    Why it's wrong here

    The expression produces the float 10.0; bool would only arise from a comparison or explicit bool() call, and Python does not coerce numeric results to booleans. It is tempting because booleans behave as 0 and 1 in arithmetic, and would be correct if avg held the outcome of a condition such as a > b.

  • ✗

    int

    Why it's wrong here

    Python 3 division always yields a float, so (5+10+15)/3 gives 10.0, not an int. The option tempts because the operands are integers and the result is a whole number, but true division never truncates to int; int would only arise from floor division (//) or explicit casting.

  • ✗

    str

    Why it's wrong here

    Division with the / operator always yields a float in Python 3, so avg holds 10.0, not text. str is tempting because the value could be converted for display, and would be correct had the code wrapped the result in str() or used string concatenation.

About these practice questions

This PCEP question is part of Courseiva's 482-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.