PCEP Computer Programming and Python Fundamentals Practice Question
A developer writes a function that returns multiple values. How should they return these values?
⚠ Common exam trap
The PCEP exam often tests the distinction between returning multiple values as a tuple (comma-separated) versus returning a single container object like a list, tricking candidates who think lists are the only way to return multiple items.
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
✓
return a, b
In Python, a function can return multiple values by separating them with commas in the return statement. This automatically packs them into a tuple, which is then unpacked by the caller. Option A correctly uses `return a, b`, which returns a tuple `(a, b)`, allowing the caller to assign the results to separate variables.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
return a, b
Why this is correct
This returns a tuple containing a and b.
- ✗
return a+b
Why it's wrong here
This returns a single value, the sum, not multiple values.
- ✗
return [a,b]
Why it's wrong here
This returns a list, which is also possible but not the typical multi-value return idiom.
- ✗
return a; return b
Why it's wrong here
The second return is unreachable; only the first return executes.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCEP question from scratch — 498 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. 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.