Technology Tuples | Python Tutorial

Learn with diagrams, code, systems and practical examples.

</>
Tutorials›Python›Tuples
Data Structures · Chapter 11

Tuples

Represent small ordered groups of values that should not be changed in place.

Why this matters

Tuples are useful when a group of values belongs together and should behave like a stable record or key.

Start with the idea

A tuple is ordered like a list but immutable. That makes tuples useful for fixed coordinates, function returns, and composite dictionary keys when their contents are hashable.

IdeaUnderstand the purpose
→
CodeRun the smallest example
→
PracticeChange it yourself
SubjectVision learning pattern: understand the idea before memorizing syntax.

Small working example

Run this example first. Do not change several things at once; confirm the basic behavior, then experiment.

Python
location = (34.05, -118.24)
lat, lon = location
print(lat)
print(lon)
Expected output
34.05
-118.24
What to notice

The example is intentionally small. Focus on the chapter’s main idea before adding extra syntax or framework code.

Common beginner mistake

Mistake

Choosing a tuple merely because it uses fewer characters than a small class or dataclass.

Better approach

Use tuples for simple positional groups; use named structures when field meaning should be explicit.

Quick recap

  • Tuples are ordered.
  • Tuples are immutable.
  • Unpacking gives names to tuple positions.

Try it yourself

These are deliberately small. If you can complete them without copying the example, you are ready to continue.

  1. Create a three-value tuple and unpack it.
  2. Compare when a tuple versus a list better describes your data.