Question 198 of 498
PCEP Practice Question: Functions, Tuples, Dictionaries and Exceptions
A developer writes a function that returns multiple values as a tuple. Which of the following is a valid way to unpack the result into separate variables?
⚠ Common exam trap
Python Institute often tests the requirement that the number of variables on the left must exactly match the number of elements in the returned tuple, so candidates who choose option B fall into the trap of assuming extra variables are simply ignored or set to `None`.
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
✓
a, b = func()
When a function returns multiple values as a tuple, Python allows tuple unpacking directly in an assignment statement. The syntax `a, b = func()` automatically unpacks the two-element tuple into the variables `a` and `b`, which is the standard and most Pythonic way to handle such a return.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
result = func(); a, b = result[0], result[1]
Why it's wrong here
This works but is not unpacking.
- ✗
a, b, c = func()
Why it's wrong here
Unpacking mismatch if function returns only two values.
- ✗
a = func()[0]; b = func()[1]
Why it's wrong here
This calls the function twice.
- ✓
a, b = func()
Why this is correct
This is direct tuple unpacking.
Visual reference
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Last reviewed: Jun 30, 2026
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.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.