Session 2 You are looking ahead. This session opens once session 1 is finished; until then it is here to read. Today is session 1
A loop, its order, and a running total
In this session you write your first loop: it goes through six rows of sales, one at a time, and keeps a running total. In SQL, SUM(amount) added the whole column at once; here you decide where in your code the total starts.
This page shows the session as it looks before you start. The trial keeps your progress in this browser: open a part and it picks up where you left it, and the board reads the same record.
Where this comes from
The skill and how hard it is come from those courses; this task was written here. Checked 2026-11-10.
Six rows are waiting in a file called rows.py; each has a name, a team and an amount. You will fetch the file, write a loop over the rows at the bottom of it, count some of them, and keep a running total until it passes 50. The file stays as it is, so you can check every answer by hand. Your readings loop over a count; these rows are not a count, and the page shows you the difference before the first task.
Fetch rows.py into ~/cs-core with curl -O, open it, and write a loop at the bottom that prints each person’s name.
Uses: what this page shows above · the reference card on this page
Below that, count the rows whose amount is more than 20, and add those amounts up. Print the count, then the sum.
Uses: what this page shows above · MIT 6.100L, Lecture 2: Strings, Input/Output, Branching — the lecture-notes PDF, the branching half
Add the amounts up in the order the rows come. The moment the running total passes 50, print that row’s name and the total at that moment, and stop.
Uses: what this page shows above · MIT 6.100L, Lecture 3: Iteration — the lecture-notes PDF
No clock on this card. The session is done when you can do the thing, whether that took forty minutes or three sittings.