PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
A developer runs the following code: x = 0.1; y = 0.2; print(x + y == 0.3). What is the output and why?
⚠ Common exam trap
Python Institute often tests the misconception that Python performs exact decimal arithmetic, leading candidates to expect True, when in fact the binary floating-point representation causes a small rounding error that makes the comparison False.
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
✓
False, due to floating-point precision
Floating-point numbers in Python (and most programming languages) are stored in binary (IEEE 754 double-precision), and values like 0.1 and 0.2 cannot be represented exactly. The sum 0.1 + 0.2 yields a result slightly greater than 0.3 (approximately 0.30000000000000004), so the equality comparison returns False.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
False, because the + operator is not defined for floats
Why it's wrong here
The + operator works on floats.
- ✗
True, because Python rounds to 0.3
Why it's wrong here
Python does not round automatically; the result is 0.30000000000000004.
- ✗
True, because Python uses decimal arithmetic
Why it's wrong here
Python uses binary floating-point, not decimal.
- ✓
False, due to floating-point precision
Why this is correct
0.1+0.2 equals 0.30000000000000004, not exactly 0.3.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCEP question from scratch — 498 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 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.