The essentials
A loop repeats instructions. Python’s range(n) produces integers starting at 0 and stopping before n.
Trace each iteration to see how a running total changes. No code is executed on this site; these are reading exercises.
Worked example
total = 0
for i in range(3):
total = total + i
The values of i are 0, 1 and 2. The final total is 3.