PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
Consider: x = True; y = False; z = x and not y or x. What is the value of z?
⚠ Common exam trap
Python Institute often tests operator precedence by combining `and`, `or`, and `not` in a single expression, trapping candidates who incorrectly assume left-to-right evaluation without respecting that `not` binds first, then `and`, then `or`.
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
✓
True
The expression `x and not y or x` is evaluated with operator precedence: `not` has the highest precedence, then `and`, then `or`. Given `x = True` and `y = False`, `not y` evaluates to `True`. Then `x and True` is `True and True`, which is `True`. Finally, `True or x` (where `x` is `True`) short-circuits to `True`. Thus, `z` is `True`.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
True
Why this is correct
Correct; expression evaluates to True.
- ✗
None
Why it's wrong here
Incorrect; result is boolean, not None.
- ✗
Error
Why it's wrong here
No error; valid expression.
- ✗
False
Why it's wrong here
Incorrect; all subexpressions lead to True.
Go deeper
Related to this question
About these practice questions
One of 498 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 →
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.