In The Hitchhiker's Guide to the Galaxy, the answer to life, the universe, and everything is 42.
Let's explore more useful modules! The statistics module does statistical calculations:
import statistics
data = [10, 20, 30, 40, 50]
print(statistics.mean(data)) # 30
print(statistics.median(data)) # 30
print(statistics.stdev(data)) # 15.811...
The string module has useful constants:
import string
print(string.ascii_lowercase) # abcdefghijklmnopqrstuvwxyz
print(string.digits) # 0123456789
📋 Instructions
Find the answer to everything!
Given these test scores:
```python
scores = [85, 92, 78, 95, 88, 42, 90, 76, 84, 91]
```
Use the `statistics` module to print:
```
Mean: 82.1
Median: 86.5
Highest: 95
Lowest: 42
The answer to everything: 42
```
Use `max()` and `min()` for highest/lowest.
Use statistics.mean(), statistics.median(), max(), min(). You've got this — take it step by step!
⚠️ Try solving it yourself first — you'll learn more!
import statistics
data = [10, 20, 30, 40, 50]
print(statistics.mean(data)) # 30
print(statistics.median(data)) # 30
print(statistics.stdev(data)) # 15.811...