Courseiva

PCEP Computer Programming and Python Fundamentals Practice Question

A developer wants to store a collection of unique employee IDs that will be checked frequently for membership. Duplicate IDs must be automatically ignored, and the order of IDs does not matter. Which built-in data type best fits this requirement?

⚠ Common exam trap

The trap here is reaching for a dictionary because both it and a set guarantee uniqueness, forgetting that a dictionary demands a value for each key and models pairs rather than a plain collection.

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

The set type is designed for unordered collections of unique hashable elements. Adding an existing employee ID leaves the set unchanged, and the in operator performs an average constant-time membership test thanks to hashing. Since the order of IDs is irrelevant and duplicates must be eliminated automatically, a set matches the described requirements more directly than any ordered sequence or key-value mapping.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    set

    Why this is correct

    A set stores only unique elements and automatically discards duplicates when items are added. Its hash-based implementation provides average constant-time membership testing with the in operator, which suits frequent ID lookups. Because the order of employee IDs is explicitly unimportant, the set's unordered nature is not a drawback for this requirement.

  • ✗

    dict

    Why it's wrong here

    A dictionary stores key-value pairs and requires a value for every key, which adds unnecessary structure when only IDs are needed. Keys are unique, so duplicates would be overwritten, but membership tests check keys rather than standalone values. Using a dictionary here works technically yet misrepresents the data model and consumes extra memory compared with a plain set.

  • ✗

    list

    Why it's wrong here

    A list preserves order and allows duplicates, so adding the same employee ID twice would store it twice. Membership tests scan elements one by one, which becomes slower as the collection grows. Because the requirement is automatic removal of duplicates and fast membership checks, a list does not satisfy the stated needs even though it can hold the IDs.

  • ✗

    tuple

    Why it's wrong here

    A tuple is immutable, so new employee IDs could not be added after creation without building a whole new tuple. It also permits duplicate values and performs linear membership scans. Since the scenario requires an evolving collection with unique entries and quick lookups, a tuple is unsuitable despite being an ordered sequence type.

About these practice questions

One of 482 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 →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Python Institute exam blueprint

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.