PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
A program evaluates the expression: (True or False) and not (True and False). What is the result?
⚠ Common exam trap
Python Institute often tests the precedence of `not` over `and` and `or`, so the trap here is that candidates incorrectly apply `not` to the entire expression or forget that `not` binds tighter than `and`, leading them to evaluate `not (True and False)` as `False` instead of `True`.
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 `(True or False) and not (True and False)` evaluates step by step: `True or False` is `True`, `True and False` is `False`, `not False` is `True`, and finally `True and True` is `True`. In Python, boolean operators `or`, `and`, and `not` follow standard precedence (`not` highest, then `and`, then `or`), and the result is a boolean value.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Error
Why it's wrong here
Boolean operators on True and False operands always yield a bool; no exception is raised, so an error cannot occur. Errors arise from type mismatches such as comparing incompatible objects, which is the scenario where this answer would apply, not a well-formed expression of literals.
- ✗
None
Why it's wrong here
None is a value returned by functions lacking a return statement, not a product of boolean evaluation. The and, or and not operators always return one of their operands, so a literal expression of True and False values cannot yield None.
- ✗
False
Why it's wrong here
Evaluating left to right: (True or False) is True; (True and False) is False; not False is True; True and True is True. False would result only if the negation applied to the whole conjunction, which the parentheses here prevent.
- ✓
True
Why this is correct
'True or False' short-circuits to True, and 'True and False' evaluates to False, so 'not False' becomes True. The expression reduces to True and True, which yields True under Python's operator precedence, where not binds tighter than and.
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 →
Same concept, more angles
2 more ways this is tested on PCEP
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Consider: x = True; y = False; z = x and not y or x. What is the value of z?
hard- ✓ A.True
- B.None
- C.Error
- D.False
Why A: 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`.
Variation 2. What is the result of the expression: (1 and 0) or (not False and True)?
hard- ✓ A.True
- B.False
- C.0
- D.1
Why A: 1 and 0 evaluates to 0 (falsy). not False evaluates to True, so not False and True evaluates to True. 0 or True evaluates to True (the last truthy value).
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.