Courseiva
Functions, Tuples, Dictionaries and ExceptionsmediumMultiple ChoiceObjective-mapped

PCEP Tuple unpacking Practice Question

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])

⚠ Common exam trap

Candidates may think only one syntactic form is correct, but assignment target lists can be parenthesized or bare; both perform tuple unpacking.

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) = result

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.

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 = result[0]; b = result[1]

    Why it's wrong here

    Incorrect: This accesses elements by index, not tuple unpacking.

  • (a, b) = result

    Why this is correct

    Correct: Parenthesized target list unpacks the tuple into a and b.

  • a, b = result

    Why this is correct

    Correct: Bare target list unpacks the tuple — the most concise form.

  • a = result[1]; b = result[0]

    Why it's wrong here

    Incorrect: This accesses elements by index and swaps the order.

Visual reference

Client Server SYN (seq=100) SYN-ACK (seq=200, ack=101) ACK (ack=201) Connection established — data transfer begins

About these practice questions

One of 498 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 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.