PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
Which TWO of the following are Python membership operators?
⚠ Common exam trap
Python Institute often tests the distinction between membership operators ('in', 'not in') and identity operators ('is', 'is not'), as candidates frequently confuse 'is' with 'in' or mistake 'not' as a standalone membership operator when it must be paired with 'in'.
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
✓
not in
Option B, 'not in', is a Python membership operator that evaluates to True when a specified value is absent from a sequence such as a list, tuple, string, or dictionary, making it correct. Option C, 'in', is likewise a membership operator that tests whether a value exists within a sequence, returning a Boolean result, so it is also correct. The other options are not membership operators: A 'not' is a logical (Boolean) operator, D 'is' is an identity operator that compares object identity, and E 'and' is a logical operator that combines Boolean expressions.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
not
Why it's wrong here
`not` is a unary logical operator returning a Boolean negation, not a membership test. It is tempting because it appears alongside `in` in conditional expressions, yet `in` and `not in` are the membership operators; `not` alone would be correct only for inverting a truth value.
- ✓
not in
Why this is correct
'not in' is a membership operator that evaluates whether a value is absent from a sequence, returning a Boolean. It is the negated counterpart of 'in', satisfying the question's requirement for membership operators rather than identity or comparison operators.
- ✓
in
Why this is correct
'in' is a membership operator that tests whether a value exists within a sequence such as a string, list or tuple, returning True or False. It satisfies the question's requirement, unlike identity operators (is) or comparison operators.
- ✗
is
Why it's wrong here
`is` is an identity operator comparing object references, not membership. It is tempting because it resembles `in` syntactically and appears in similar conditional contexts, but identity testing is distinct; `is` would be correct when checking whether two names reference the same object.
- ✗
and
Why it's wrong here
`and` is a Boolean logical operator combining two expressions, not a membership test. It is tempting because it frequently appears with `in` inside conditions, but membership requires `in` or `not in`; `and` would be the correct choice for questions about logical operators.
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.