PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
Which TWO of the following expressions will evaluate to True?
⚠ Common exam trap
Python Institute often tests the confusion between value equality (==) and identity equality (is), especially with integers and floats, where candidates mistakenly think '3 is 3' is False or that '3 != 3.0' is True due to type differences.
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
✓
3 == 3.0
Option D (3 == 3.0) is correct because the == operator performs value equality, and in Python the integer 3 and the float 3.0 compare equal since 3.0 has no fractional part. Option E (3 is 3) is correct because small integers in the range -5 to 256 are interned (cached) by CPython, so both literals 3 reference the same int object, making the identity comparison True. Option A (3 is not 3) is wrong because it is the exact negation of E, which is True, so A evaluates to False. Option B (3 > 2 and 2 > 3) is wrong because although 3 > 2 is True, 2 > 3 is False, and the and operator returns False. Option C (3 != 3.0) is wrong because 3 == 3.0 is True, so the inequality 3 != 3.0 evaluates to 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.
- ✗
3 is not 3
Why it's wrong here
Identity comparison with 'is not' returns False when both operands are the same object, and small integer 3 is cached, so 3 is not 3 evaluates to False. It tempts because 'is not' genuinely tests object non-identity, which would be True for two distinct equal-valued objects, such as separate list instances.
- ✗
3 > 2 and 2 > 3
Why it's wrong here
The and operator requires both operands True; 2 > 3 is False, so the whole expression is False. It tempts because the first comparison 3 > 2 is True, and candidates overlook that conjunction fails when any operand is False, not just the first.
- ✗
3 != 3.0
Why it's wrong here
In Python, 3 and 3.0 compare equal numerically, so 3 != 3.0 evaluates to False. It tempts because the operands differ in type (int versus float), suggesting inequality, but Python's numeric comparison ignores representation and compares value, making the expression False.
- ✓
3 == 3.0
Why this is correct
Numeric equality in Python compares mathematical value, not type, so the integer 3 and the float 3.0 are considered equal. The `==` operator returns True here, satisfying the stem's requirement for an expression evaluating to True. This differs from identity comparison (`is`), which would return False.
- ✓
3 is 3
Why this is correct
`3 is 3` evaluates to True because CPython caches small integers from -5 to 256, so both literals reference the same int object, making the identity comparison succeed. This satisfies the stem's requirement for an expression returning True, though the behaviour relies on implementation-specific interning rather than language guarantee.
Go deeper
Related to this question
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 →
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.