PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
A developer needs to store a large collection of unique user IDs (integers) and quickly check if a new ID already exists. Which data type is most appropriate for this task?
⚠ Common exam trap
Python Institute often tests the misconception that a dict is required for any kind of lookup, when in fact a set is the correct choice for membership testing without associated data.
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
✓
set
A set is the most appropriate data type because it stores unordered collections of unique elements and provides O(1) average-time complexity for membership testing using the `in` operator. This makes it ideal for quickly checking if a new user ID already exists without needing to manage keys or maintain order.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
dict
Why it's wrong here
Incorrect: dict can work but is not the most direct; set is designed for this.
- ✗
list
Why it's wrong here
Incorrect: list membership test is O(n).
- ✓
set
Why this is correct
Correct: set provides fast membership and uniqueness.
- ✗
tuple
Why it's wrong here
Incorrect: tuple is immutable and membership test is O(n).
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.