a trial — your progress is kept in this browser only

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.

Why this one is hereYou write a loop over six rows, few enough to check by eye, that keeps a running total. Watch where you set the total to zero: Python accepts more than one place without an error. A1, this block of sessions, ends with an agent’s script whose weekly total jumped 12% for no business reason, and a loop like this is at its centre.
Read this first65 min · the material itself, not my summary of it
MIT 6.100L, Lecture 2: Strings, Input/Output, Branching — the lecture-notes PDF, the branching half asking whether something is true, and doing one thing only if it is25 min
MIT 6.100L, Lecture 3: Iteration — the lecture-notes PDF a loop, and a value that changes while it runs30 min
MIT 6.100L — Finger Exercise, Lecture 3 one loop you write yourself, before this lab’s own: a count, and a line inside it10 min
This session has four parts
1No-help check18 min
2Loop over six rows, count some, keep a running totalthe lab · below
3Read how Spliit is put togethertake something apart · 30 min
4Talk through someone else’s codeinterview · 30 min
The lab · three things, stop anywhere
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.

AI may explain, never write or debug.stuck 15 min is normal
1
Fetch the rows and print them

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

2
Count the ones over twenty

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

3
Keep a running total across the rows

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.