Courseiva

PCEP Practice Question: Functions, Tuples, Dictionaries and Exceptions

A programmer needs to store a fixed set of error codes that should not change during program execution. Which data type is most appropriate for this purpose?

⚠ Common exam trap

Many exam-takers confuse immutability with uniqueness or assuming that any collection type can serve as a constant.

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

✓

tuple

A tuple is an immutable sequence, so its contents cannot be altered after creation. This ensures that the set of error codes remains constant throughout the program's execution. While lists, dictionaries, and sets can hold multiple values, they are all mutable, meaning they could be accidentally modified. The immutability of tuples makes them the most appropriate choice for storing fixed data.

Answer analysis

Option-by-option breakdown

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

  • ✓

    tuple

    Why this is correct

    A tuple is immutable, so once it is created, its elements cannot be changed. This makes it ideal for storing a fixed set of error codes that should not be modified during program execution. The programmer can be confident that the collection remains constant, preventing accidental changes. Tuples also support indexing and iteration, making them convenient for lookups.

  • ✗

    dictionary

    Why it's wrong here

    A dictionary stores key-value pairs and is mutable. It is useful for mapping error codes to descriptions, but if the requirement is simply to store a fixed set of codes, a dictionary adds unnecessary complexity. The keys can be changed, which violates the immutability requirement. A tuple is more appropriate for a simple immutable sequence.

  • ✗

    set

    Why it's wrong here

    A set is mutable and unordered. It is excellent for membership testing and eliminating duplicates, but it does not preserve order and its elements can be added or removed. For a fixed set of error codes that should not change, a set does not enforce immutability. A tuple provides an immutable sequence, which better matches the requirement.

  • ✗

    list

    Why it's wrong here

    A list is mutable, meaning its elements can be changed, added, or removed after creation. While a list can hold error codes, it does not enforce immutability. If the programmer wants to ensure the set of codes remains constant, a list is not the best choice because accidental modification is possible. Tuples are better suited for fixed collections.

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.