Year 7 Computing — Repeating with loops
Read a loop, work out how many times it runs, and follow the value it builds up to the end.
Name: ________________________
1.Follow this code by hand. What is total at the end?
total = 0 for i in range(0, 4): total = total + 62.A program sets a number to 3. It repeats this 3 times: double the number. What is the number at the end?
3.A program sets a total to 0. It repeats this 3 times: add 8 to the total. What is the total at the end?
- a) 24
- b) 3
- c) 8
- d) 11
4.A program repeats this 4 times: print 3 stars. How many stars are printed?
5.A program sets a number to 1. It repeats this 4 times: double the number. What is the number at the end?
6.A program sets a number to 2, then doubles it three times over. Put the values the number holds in order, from the start to the end.
- 2
- 8
- 16
- 4
7.A program sets a total to 100. It repeats this 5 times: take 20 away from the total. What is the total at the end?
8.A program repeats this 6 times: print a star. How many stars are printed?
Answer key — Year 7 Computing — Repeating with loops
- 1. 24
- 2. 24
- 3. a) 24
- 4. 12
- 5. 16
- 6. 1. 2 2. 4 3. 8 4. 16
- 7. 0
- 8. 6