Your Spreadsheet Is Already a Database
Every student has asked a data question without calling it one: what is my average, who scored highest, how many of us passed, where did my money go this week. The answers sit in a table somewhere — a spreadsheet, a download, a list in your notes. One small program bridges the gap, and that program is your first data project.
Data work starts with code you already know: read a list, add numbers up, find the biggest one, keep the ones that pass a test. If you can write a loop and an if statement, you can analyse data. The format that makes it easy is the CSV — comma-separated values — a spreadsheet written out as plain text.
What a CSV Actually Is
A spreadsheet is a grid: column names across the top, one row per student, one number per cell. A CSV is that grid with the lines replaced by commas and the rows separated by new lines. The first line is the header — it names the columns — and every line after it is one row of data.
That is why CSV is everywhere: spreadsheets, survey tools, and most apps that let you download your data all offer it. If you can read a table, you can read a CSV — and the code is shorter than you expect.
Try It: Four Students, Seven Answers
Paste it into the browser editor and run it — the data is pasted right into the program, so there is no file to upload.
# scores.py - your first data project: a CSV becomes answers
import csv
import io # A CSV is a spreadsheet with commas: one header row,
# then one row per student. Paste your own numbers here.
DATA = """name,quiz1,quiz2,quiz3
Asha,82,91,77
Ben,64,58,71
Cara,95,88,93
Dan,41,55,49
""" def load(text): rows = list(csv.DictReader(io.StringIO(text))) for row in rows: row["scores"] = [int(row["quiz1"]), int(row["quiz2"]), int(row["quiz3"])] return rows def average(numbers): return sum(numbers) / len(numbers) def report(text): students = load(text) if not students: return "No students yet." for student in students: student["avg"] = average(student["scores"]) best = max(students, key=lambda s: s["avg"]) passed = [s for s in students if s["avg"] >= 60] class_avg = average([s["avg"] for s in students]) lines = ["%s: %.1f" % (s["name"], s["avg"]) for s in students] lines.append("Class average: %.1f" % class_avg) lines.append("Top student: %s (%.1f)" % (best["name"], best["avg"])) lines.append("Passed: %d of %d" % (len(passed), len(students))) return "\n".join(lines) print(report(DATA))
print("---")
print(report("name,quiz1,quiz2,quiz3\n"))
print("---")
print(report("name,quiz1,quiz2,quiz3\nEli,100,100,100\n"))The output is three blocks. The first prints one line per student — Asha 83.3, Ben 64.3, Cara 92.0, Dan 48.3 — then the answers: 72.0 average, top student Cara at 92.0, 3 of 4 passed. The second is the empty file and prints "No students yet." instead of crashing. The third is a class of one: Eli scores 100.0, 1 of 1 passed. Three datasets, one function.
The program never hard-codes a name or a score into the answer. The names and numbers live in DATA, and every answer is computed from them. Change a score and the answers change — you write the rule that finds them.
Three Small Tools Do All the Work
The first tool is load(), which turns text into rows. csv.DictReader reads the header line and turns each following line into a dictionary keyed by the header names, so row["quiz1"] is the first quiz score by name. io.StringIO wraps the pasted text so DictReader can read it as if it came from a file — swap one line later to read a real file instead.
The second tool is average(): sum divided by count. It runs twice — once for each student's three quizzes, once for the class average. Write it once and reuse it: a function you trust on one list, you trust on every list.
The third tool is a pair: max() with a key, and a list filter. max(students, key=lambda s: s["avg"]) asks for the student with the biggest average, and the key tells max what "biggest" means. The filter [s for s in students if s["avg"] >= 60] keeps only the students who cleared 60. Average, best, who passed — those three answer almost every first data question.
What Breaks, and What It Teaches You
Real data is messy, and the errors it produces are the most useful part of this project: each one names the exact problem. Take the empty file first: without the if not students guard, max() on an empty list raises ValueError: max() iterable argument is empty. There is no best student in an empty class, so the program checks first and returns "No students yet." instead.
Then the missing value: a row like Fay,90,,80 has an empty cell where quiz2 should be, and int("") raises ValueError: invalid literal for int() with base 10. The crash is honest: the data is missing, and guessing would be worse than stopping. Decide the rule first: skip the row, count a missing quiz as zero, or ask whoever made the file.
Finally, average() itself: call it on an empty list and 0 / 0 raises ZeroDivisionError. The first-test habit guards against the same crash, and it is why the guard in report() matters. When a data program crashes, read the error type first: ValueError means the data is wrong, ZeroDivisionError means a list is empty.
Make It Yours: Your Own Numbers
The fastest way to make this yours is to swap the data, not the code. Replace the four students with your own quiz scores, your study hours, or your spending from the budget tracker — same columns, different numbers, same answers. Then change the question: add a fourth quiz, or change 60 to 75 and see who passes now. One change and one run each.
Next, ask a question the program cannot answer yet: which quiz was hardest for the class, or who improved most from quiz1 to quiz3. Both are one average and one subtraction away. Data projects grow one question at a time.
From a Snippet to a Portfolio Piece
When it prints answers about your own numbers, save it as a snippet called "first-data-project" with a one-line note: "reads a CSV of quiz scores, prints averages, top student, and pass count." That note turns saved code into study material — your snippet library is your revision notes. Then push it to GitHub with a short README, following the portfolio guide: a program that answers real questions about real data says what a tutorial copy cannot.
It is also the start of a longer path: the same three tools — average, best, filter — work on any table you meet later, from a class survey to a part-time job's sales sheet. The Lab courses build the same ideas into a full learning path, and interview practice there will ask you to do this out loud, with data you have never seen.
When the Free Plan Runs Out
Data ideas burn executions fast. Free gives you 20 executions a day, 10 AI requests a day, 10 saved snippets, 3 private snippets, and 3 collaborators per snippet — enough for one careful project a day. When you start analysing data daily, that is the upgrade moment: Pro is $9/month or $69/year — unlimited saved snippets and executions, 100 AI requests a day, 10 collaborators per snippet, unlimited private snippets, and GitHub integration, which Free does not include. Team ($19/user/month, or $15/user/month billed annually) covers a class or study group analysing data together — see the pricing page.
Your next step is tonight: paste the code above into the browser editor, run it, and watch it print the class average, the top student, and the pass count. Then swap in your own numbers — your quizzes, your study hours, your spending — run it again, and save it as a snippet called "first-data-project". Tomorrow, add a column and a question. The first time your code turns a table into an answer, a spreadsheet stops being something you stare at and becomes something you can ask.