Learning overview
- Estimated time
- 4 minutes
- Difficulty
- Beginner
- Prerequisites
- No prior experience required
- Learning outcome
- Explain python using a clear mental model · Apply python in practical Python work
- Last updated
- July 18, 2026
Use tuples for fixed positional records
Coordinates, RGB values, and small function returns can use tuples when each position has a clear meaning. For larger domain records, named tuples or frozen dataclasses communicate fields more clearly.
point = (12, 8)
x, y = point
head, *middle, tail = ("HTML", "CSS", "Python", "SQL")
def dimensions() -> tuple[int, int]:
return 1280, 720Understand tuple immutability
A tuple cannot replace, add, or remove positions. A tuple can still contain a mutable list, and that nested list can change. Hashability depends on every contained value being hashable.
Choose tuple, list, or dataclass
Use a list for a changing homogeneous sequence, a tuple for a compact fixed positional record, and a dataclass when named fields and domain behavior improve clarity.
Frequently asked questions
Are Python tuples always hashable?
No. A tuple is hashable only when every element it contains is hashable. A tuple containing a list cannot be a dictionary key.
Why does a one-item tuple need a comma?
The comma creates the tuple; parentheses primarily group expressions. Write (value,) or value, for a one-item tuple.
Topic graph
A taxonomy-generated path through this subject.
Related courses
Related learning
Recommended automatically from shared technologies, topics, intent, and difficulty.
Related Guides
Related Tutorials
Related Glossary
Related Cheatsheets
Related Projects
Related Interview Questions
Related reading
Hand-picked companion pages that deepen this topic.
Your next steps
