Three thousand rows tell you nothing by staring. You need a question first — in English, at the top of your file, before any code. Then the tools are ones you already own: traverse, count, accumulate.
Notice each section starts with a question, then writes the loop that answers it. Enrolled in our Runestone course? Open it from there so your progress counts.
Big Data, powered by Programs. The file is loaded (5.3). Today the Unit 3 toolkit — traverse, count, accumulate, compare — turns rows into answers. Nothing new; that’s the point.
So: what do you actually want to know? And — the question that matters more — does this data contain what you’d need to answer it?
Every data question in this unit runs the same three steps:
# Q: How many members commute # more than 20 minutes? count = 0 for row in rows: if int(row["commute_min"]) > 20: count = count + 1 print(count)
// commutes: a list of minutes count ← 0 FOR EACH c IN commutes { IF (c > 20) { count ← count + 1 } } DISPLAY(count)
Hover or tap a line to light its twin. This is the accumulator from 3.4. The only difference is where the list came from. Python pulls a field out of each row; the AP version starts with the list already made — which is how every exam question gives it to you.
The club-signups dataset has these fields: student_id, name, grade, club, city, commute_min,
club_hours_per_week, screen_time_hours, signup_date. For each question: A = answerable
from these columns, N = not answerable.
Write three questions the club dataset can answer and one it can’t. For the one it can’t, name the missing column. Then answer one of your three with a loop — question as a comment on top.
No new terms today — on purpose. This is a fluency day: the words you need are record, field, traverse, and accumulator, and you already own all four.
Five questions. Trace the pseudocode on paper — this is exactly the exam’s item shape.
A dataset of complaints measures complaints. A dataset of app downloads measures downloads. The gap between “what was counted” and “what we wish we knew” is where most bad headlines live.