Tuples in Python
Tuples are ordered collections similar to lists, but with one key difference: they are immutable. Once created, you cannot change their content.
Tuples are useful when you want to ensure data stays the same, or when you need a lightweight, fast collection.
Creating Tuples
Use parentheses () – comma is what really creates a tuple.
Accessing Tuple Items
Same as lists – by index.
Immutability
You cannot modify tuples – no append, remove, or item assignment.
Packing and Unpacking
Create tuples by packing values, extract with unpacking.
Tuple Methods
Only count() and index() – because tuples are immutable.
When to Use Tuples
- Fixed data that shouldn't change (like coordinates)
- As dictionary keys (tuples are hashable)
- Returning multiple values from functions
- Lightweight records
Quick Quiz
Az anyagokat átnéztük és ellenőriztük, de hibák továbbra is előfordulhatnak. A tartalom kizárólag oktatási célt szolgál, ezért saját felelősségre használd, és szükség esetén ellenőrizd más forrásokkal is.
✨ Kérdezd Larát — a tanulási partnered
Fedezd fel a személyre szabott tanulási támogatást. Lara elmagyarázza az anyagot, összefoglalja a témákat és megválaszolja a kérdéseidet — az Go csomagtól elérhető.
Lara segít gyorsabban tanulni — kizárólag a ReadyTools Go, Plus és Max tagoknak.


