Python4 min read

Python Tuples

Learn about immutable sequences using tuples.

Emily Davis
December 18, 2025
0.0k0

Understand immutable lists.

Create Tuple

```python coordinates = (40.7128, -74.0060) # New York coordinates colors = ("red", "green", "blue") single = (5,) # Note the comma ```

Access Tuple Items

```python point = (10, 20, 30)

print(point[0]) # 10 print(point[-1]) # 30 (last item) ```

Tuples vs Lists

```python # List (mutable) cities = ["Miami", "Austin"] cities[0] = "Denver" # OK

Tuple (immutable) coords = (10, 20) # coords[0] = 15 # ERROR! Cannot change ```

Tuple Unpacking

```python # Assign multiple variables at once lat, lon = (34.0522, -118.2437) # Los Angeles

print(lat) # 34.0522 print(lon) # -118.2437 ```

When to Use Tuples

```python # Fixed data that shouldn't change rgb = (255, 0, 0) birthday = (1995, 6, 15) ```

Remember

- Tuples cannot be modified - Use for fixed data - Faster than lists

#Python#Beginner#Tuples