PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
What is the data type of the expression (3.14 > 2) and ('a' < 'b')?
⚠ Common exam trap
Python Institute often tests the misconception that the 'and' operator returns a Boolean only when both operands are Boolean, but in Python it can return any operand type; however, in this specific case both operands are comparisons that yield bool, so the result is bool, and candidates may incorrectly think the result is int because True/False are subclasses of int.
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
✓
bool
The expression (3.14 > 2) evaluates to True because 3.14 is greater than 2, and ('a' < 'b') evaluates to True because in Python string comparison uses lexicographic order based on Unicode code points ('a' has code point 97, 'b' has 98). The 'and' operator combines these two Boolean values, resulting in True, which is of type bool. Therefore, the entire expression's data type is bool.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
bool
Why this is correct
Both comparisons yield Boolean values, and the `and` operator returns a `bool` when combining them. This satisfies the stem's requirement for the expression's data type: `3.14 > 2` evaluates to `True`, `'a' < 'b'` evaluates to `True`, and `True and True` produces the Boolean result `True`.
- ✗
float
Why it's wrong here
The operands are comparisons producing bool values, and 'and' returns an operand rather than performing arithmetic, so no float appears. float would be correct for an expression mixing decimal literals, such as 3.14 + 2.0.
- ✗
str
Why it's wrong here
The `and` operator returns one of its operands, not a Boolean, so `(3.14 > 2) and ('a' < 'b')` yields the second operand `True` — a bool, never a str. `str` is tempting because text literals appear in the comparisons, but `str` would be correct only if the expression evaluated to a string value.
- ✗
int
Why it's wrong here
Both comparisons yield bool, and 'and' returns one of its operands, so the expression evaluates to a bool, never int. Choosing int confuses the type with numeric results of arithmetic; int would be right for an expression such as 3 + 2.
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.