PCEP Computer Programming and Python Fundamentals Practice Question
A trainee is reviewing how Python 3 handles basic data types and type conversion in a small inventory script. Which TWO statements about Python's built-in numeric and string types are correct? (Choose two.)
⚠ Common exam trap
The trap here is assuming floats store decimal values exactly and that bool sits outside the integer hierarchy, when both assumptions contradict Python's actual type model.
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
✓
Calling int('42') returns the integer 42, while int('4.2') raises a ValueError
Python 3 integers grow to whatever size memory allows, so counters never silently overflow, and int() accepts only strings that look like whole numbers, rejecting anything with a decimal point. Together these behaviours shape how inventory quantities and parsed input are handled. Floats remain binary approximations, strings stay immutable, and bool is a subclass of int rather than a separate numeric family.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Calling int('42') returns the integer 42, while int('4.2') raises a ValueError
Why this is correct
int accepts a string containing digits and optional sign, converting it to the matching integer. A string with a decimal point is not a valid integer literal, so conversion fails with ValueError. The correct path for such input is float('4.2') followed by int() if truncation is desired, making this statement an accurate description of the behaviour.
- ✗
The bool type is a distinct numeric type where True equals 1 and False equals 0 in arithmetic
Why it's wrong here
bool is a subclass of int, not a separate numeric category, and True and False behave as 1 and 0 in arithmetic. Summing a list of booleans counts the True values. Because bool inherits from int, isinstance(True, int) is True, so describing it as distinct from the numeric hierarchy is inaccurate.
- ✗
The str type is mutable, so individual characters can be replaced by index assignment
Why it's wrong here
Strings are immutable in Python; attempting something like text[0] = 'x' raises TypeError. Operations that appear to modify a string actually build and return a new object. To change content, code must create a new string, for example through slicing and concatenation or by using methods such as replace, which also return new strings.
- ✓
The int type can represent arbitrarily large whole numbers limited only by available memory
Why this is correct
Python 3 integers have unlimited precision, growing as needed to hold the value. A quantity counter that exceeds the range of a 64-bit integer simply allocates more internal digits rather than overflowing. This differs from many languages where fixed-width integers wrap or raise errors, and it makes int suitable for exact large-number arithmetic without special libraries.
- ✗
The float type stores decimal values with exact precision for any fractional number
Why it's wrong here
Floats follow the IEEE 754 binary standard and cannot represent most decimal fractions exactly. A value such as 0.1 becomes a close binary approximation, which is why comparisons and sums can show tiny discrepancies. For exact decimal arithmetic, the decimal module is used instead, so this statement misrepresents how float behaves.
Go deeper
Related to this question
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 →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Python Institute exam blueprint
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.