Skip to content
Spark & Whetstonethe grown-up commons

← Reading Code · Lesson 3 of 3

One turn at a time

About it

A loop repeats some lines. "For n from 1 to 3: total = total + n" runs three times, with n being 1, then 2, then 3.

Follow it one turn at a time in your table. If total starts at 0: after the first turn it is 1, after the second 3, after the third 6.

One question

total = 0; for n from 1 to 3: total = total + n. What is total at the end?

Say it back
A lesson is kept once you've answered the question and written at least 8 words. Nobody grades it; it stays on this device.