BeginnerCoder

Lesson 11 — Tuples & unpacking

Fixed groups

A tuple is a sequence in round brackets, like (3, 4). It is immutable — it cannot be changed after it is created — which makes it good for values that belong together, such as a point or a screen size. Unpacking assigns its parts to several variables at once, in order.

size = (1920, 1080)
width, height = size
print(width)  # 1920

Why it matters: functions often return several values as a tuple, and unpacking gives each one a clear name.

Want it another way?
Task

Unpack the point into x and y, then print their sum.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.