Year 8 · Computing · Python: loops · Lesson 3
Totals, counters and loops with if
Python loops with running totals, counters, the modulo operator and if statements inside loops, including a simple quiz program.

20-minute video lesson
Teaching, worked examples and 20 practice questions solved step by step.
Watch free for a monthWhat your child will learn
- Build a running total
- Use a counter
- Use % to find remainders
- Combine loops and if statements
- Predict program output
The method
- Set the variable to 0 before the loop.
- Add the value (total) or 1 (counter).
- Use if to choose when.
- Print after the loop.
Key words: running total, counter, modulo, if, +=, accumulator, indentation.
Worked examples
The first three practice questions from the lesson, with every step.
Question 1
What should a running total start at?
- Step 1: Before anything is added
Answer: 0
Question 2
Where should total = 0 go: inside or before the loop?
- Step 1: Inside would reset it every time
Answer: Before the loop
Question 3
What is 10 % 3?
- Step 1: 10 ÷ 3 = 3 remainder 1
Answer: 1