PCEP Practice Question: Functions, Tuples, Dictionaries and Exceptions
A function is defined as: def min_max(nums): return min(nums), max(nums). What type of value does it return?
⚠ Common exam trap
The PCEP exam often tests the misconception that multiple return values are returned as a list or that parentheses are required to create a tuple, but in Python, it is the comma that defines a tuple, not the parentheses.
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 tuple
The function `min_max` uses `return min(nums), max(nums)`, which is a comma-separated list of expressions. In Python, when multiple values are returned separated by commas, they are automatically packed into a tuple. Therefore, the function returns a tuple containing the minimum and maximum values.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
A tuple
Why this is correct
Returning comma-separated values from a function packs them into a single tuple, so `min_max` yields a two-element tuple containing the minimum and maximum. This satisfies the stem's requirement to identify the return type: the parentheses are optional, but the comma operator always constructs a tuple.
- ✗
A set
Why it's wrong here
Comma-separated values produce a tuple, not a set, which requires braces and stores unique unordered elements. It is tempting because both are collections, but without braces Python builds a tuple, preserving order and duplicates rather than hashing members.
- ✗
A dictionary
Why it's wrong here
Returning comma-separated values without brackets produces a tuple, not a dictionary, which requires key-value pairs with braces. It is tempting because both are collection types, but the absence of keys and colon syntax means Python constructs an immutable ordered tuple instead.
- ✗
A list
Why it's wrong here
Comma-separated return values form a tuple, not a list, which requires square brackets. It is tempting because both are ordered sequences, but the missing brackets mean Python creates a tuple, so the returned object lacks list methods like append.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCEP question from scratch — 482 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 →
Same concept, more angles
1 more way this is tested on PCEP
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A function returns a tuple. Which code correctly unpacks the tuple? def min_max(numbers): return min(numbers), max(numbers) result = min_max([3, 1, 2])
medium- A.a = result[0]; b = result[1]
- ✓ B.(a, b) = result
- ✓ C.a, b = result
- D.a = result[1]; b = result[0]
Why B: Both options B and C correctly unpack the tuple. Option B uses explicit parentheses, while option C uses the implicit form — both are valid tuple unpacking syntax in Python. Option A unpacks via indexing (not tuple unpacking), and option D incorrectly swaps the values.
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.