Courseiva

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

Which data type is most appropriate to store a user's age in a Python program?

⚠ Common exam trap

Python Institute often tests the distinction between numeric types by presenting a scenario where a float seems plausible (e.g., 'age could be 25.5 years'), but the PCEP expects you to recognize that age is conventionally an integer and that Python's int is the correct choice for whole-number data.

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

✓

int

A user's age is a whole number without a fractional component, so the integer type (int) is the most appropriate choice. Python's int can represent any integer value, including ages like 25 or 0, without the overhead or precision issues of floating-point numbers.

Answer analysis

Option-by-option breakdown

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

  • ✓

    int

    Why this is correct

    Age is a whole-number count of years, so int stores it exactly without floating-point rounding artefacts. A float would permit nonsensical fractional ages, while str would prevent arithmetic; int matches the discrete, countable nature of the value.

  • ✗

    float

    Why it's wrong here

    A float stores fractional values, so using it for age introduces unnecessary imprecision and permits nonsensical values such as 25.5. It tempts because numeric input is often parsed as float by default, and would be the right choice for measurements like height or weight where decimals are meaningful.

  • ✗

    bool

    Why it's wrong here

    A bool holds only True or False, so it cannot represent the range of integer ages a user might supply. It tempts because age-related questions are often binary, such as whether someone is an adult, and would be correct for storing that derived eligibility flag rather than the age itself.

  • ✗

    str

    Why it's wrong here

    A string stores text and cannot support arithmetic comparison or ordering without conversion, so age calculations and range checks would fail. It tempts because input() returns a string directly, and would be correct when the value is never used numerically, such as a postcode or phone number.

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

Same concept, more angles

1 more way this is tested on PCEP

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. Which TWO of the following are valid Python data types?

easy
  • ✓ A.int
  • B.string
  • C.char
  • ✓ D.float
  • E.double

Why A: `int` is a built-in numeric data type in Python used to represent whole numbers without a fractional component. Python's `int` type has arbitrary precision, meaning it can handle arbitrarily large integers limited only by available memory.

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.