PCEP Practice Question: Functions, Tuples, Dictionaries and Exceptions
A developer wants to create a tuple that contains a single element, the integer 5. Which of the following expressions produces exactly that?
⚠ Common exam trap
The trap here is forgetting the trailing comma in a single-element tuple, leading to the creation of an integer instead of a tuple.
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
✓
t = (5,)
A single-element tuple requires a trailing comma to distinguish it from a parenthesized expression. The expression (5,) creates a tuple containing the integer 5, while (5) is just the integer. The tuple() constructor can also be used with an iterable, but not with a single integer. The two-element tuple is incorrect because it contains two items.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
t = (5)
Why it's wrong here
(5) is just the integer 5 enclosed in parentheses, not a tuple. Parentheses are used for grouping expressions. Without a trailing comma, Python interprets this as an int. To create a single-element tuple, a comma is required.
- ✗
t = (5, 5)
Why it's wrong here
This creates a tuple with two elements, both 5. While it is a tuple, it does not contain a single element as required. The presence of two items makes it a two-element tuple, which is not what the developer wants.
- ✗
t = tuple(5)
Why it's wrong here
The tuple() constructor expects an iterable, such as a list or string. Passing an integer raises a TypeError because integers are not iterable. To create a tuple from a single element, you would need to pass an iterable containing that element, like tuple([5]).
- ✓
t = (5,)
Why this is correct
The trailing comma after 5 is crucial; it tells Python that this is a tuple with one element. Without the comma, (5) would be an int. This is the standard way to create a single-element tuple.
Go deeper
Related to this question
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 →
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.