Tutorials · Chapter D (4/4) · ~9 min
Data: tables and simple plots
Play → read → next
Read a tiny table, compute stats, and show a plot you can screenshot.
Code Lab
Data: tables & simple stats
Run the average, then print the top student name.
Recap
What you just did
You loaded a small dataset, asked it plain questions (average? extreme?), and drew a simple plot. That’s the builder habit: look first, model second. You can open the result and say, “Here’s the table I measured — and the picture of it.”
Teach
How it works
Think of a table as rows of examples:
# each row: [feature, label]
rows = [[2, 0], [5, 1], [3, 0], [8, 1]]
xs = [r[0] for r in rows]
print("mean x:", sum(xs) / len(xs))
print("max x:", max(xs))
- Table → columns you can name (feature, label)
- Stat → one number that summarizes a column
- Plot → a shape your eyes catch faster than a list
Mental model: stats answer “what’s typical?”; plots answer “what’s weird?”
Use it
When you'd use this
- Checking a CSV before you trust a prediction
- Spotting one giant outlier that would trick a model
- Showing a teammate “the data looks like this” instead of guessing
Watch out
Watch out
A pretty chart can still lie if the wrong column is plotted. Always match the axis label to the question you’re answering. Empty rows and missing values will break averages — glance at the raw rows once.
Try next
Try this next
Compute the min of your feature column the same way you did the max. Does the plot make that min obvious?