Python Data Structures at a Glance
Python Data Structures at a Glance
```python
shopping = ["apples", 42, True]
shopping.append("oranges") # Adds new item
```
```python
dimensions = (1920, 1080)
width, height = dimensions # Easy unpacking
```
```python
user = {"name": "Alex", "posts": 42}
print(user["name"]) # Fast access
```
```python
tags = {"python", "coding", "tutorial", "python"}
print(tags) # {'python', 'coding', 'tutorial'}
```
## **Specialized Types**
```python
from array import array
temps = array('f', [22.5, 18.0, 30.2])
```
```python
greeting = "Hello World!"
print(greeting.upper()) # "HELLO WORLD!"
```
**Pro Tip:** Choose lists for flexibility, tuples for safety, dictionaries for quick lookups, and sets
for uniqueness. Arrays optimize numeric work, while strings handle all text needs.