Electronics Worksheet: Loops and Variables
Remember (Trace every pass): count = count + k adds k each time round; after n rounds: start + n × k. A loop inside a loop runs outer × inner times. while (condition) repeats until the condition is false — count the rounds as you trace.
NameDateTime takenScore ___ / 40
-
1.🔁 x = 4
repeat 2 times { x = x × 2 }
What is x at the end? -
2.🔁 repeat 4 times { repeat 4 times { beep } }
How many beeps are there? -
3.🔁 count = 8
repeat 7 times { count = count + 9 }
What is count at the end? -
4.🔁 x = 1
repeat 2 times { x = x × 2 }
What is x at the end? -
5.🔁 x = 5
repeat 1 time { x = x × 2 }
What is x at the end? -
6.🔁 x = 5
repeat 4 times { x = x × 2 }
What is x at the end? -
7.🔁 repeat 4 times { repeat 5 times { beep } }
How many beeps are there? -
8.🔁 count = 10
repeat 8 times { count = count + 9 }
What is count at the end? -
9.🔁 repeat 6 times { repeat 5 times { beep } }
How many beeps are there? - 10.🔁 What does a variable do in a program? (a) joins two wires (b) blinks an LED (c) stores a value (d) measures light
-
11.🔁 total = 0
for i = 1 to 6 { total = total + i }
What is total at the end? - 12.🔁 What does “count = count + 1” do? (a) adds 1 to count (b) prints 1 (c) sets count to 1 (d) takes 1 away
-
13.🔁 x = 4
repeat 1 time { x = x × 2 }
What is x at the end? -
14.🔁 repeat 2 times { repeat 5 times { beep } }
How many beeps are there? -
15.🔁 count = 4
repeat 3 times { count = count + 7 }
What is count at the end? -
16.🔁 total = 0
for i = 1 to 9 { total = total + i }
What is total at the end? -
17.🔁 total = 0
for i = 1 to 4 { total = total + i }
What is total at the end? -
18.🔁 repeat 5 times { repeat 4 times { beep } }
How many beeps are there? -
19.🔁 x = 5
repeat 2 times { x = x × 2 }
What is x at the end? -
20.🔁 count = 9
repeat 10 times { count = count + 3 }
What is count at the end? -
21.🔁 count = 0
repeat 7 times { count = count + 9 }
What is count at the end? -
22.🔁 count = 1
repeat 8 times { count = count + 9 }
What is count at the end? -
23.🔁 count = 3
while (count < 12) { count = count + 3 }
How many times does the loop run? -
24.🔁 total = 0
for i = 1 to 11 { total = total + i }
What is total at the end? -
25.🔁 count = 0
repeat 5 times { count = count + 9 }
What is count at the end? -
26.🔁 total = 0
for i = 1 to 7 { total = total + i }
What is total at the end? -
27.🔁 count = 3
while (count < 27) { count = count + 4 }
How many times does the loop run? -
28.🔁 count = 1
repeat 5 times { count = count + 10 }
What is count at the end? -
29.🔁 count = 9
repeat 9 times { count = count + 6 }
What is count at the end? -
30.🔁 x = 4
repeat 3 times { x = x × 2 }
What is x at the end? -
31.🔁 count = 5
while (count < 11) { count = count + 3 }
How many times does the loop run? -
32.🔁 repeat 3 times { repeat 3 times { beep } }
How many beeps are there? -
33.🔁 repeat 6 times { repeat 4 times { beep } }
How many beeps are there? -
34.🔁 count = 4
while (count < 10) { count = count + 2 }
How many times does the loop run? -
35.🔁 count = 2
while (count < 6) { count = count + 2 }
How many times does the loop run? -
36.🔁 repeat 6 times { repeat 6 times { beep } }
How many beeps are there? -
37.🔁 count = 7
repeat 10 times { count = count + 6 }
What is count at the end? -
38.🔁 count = 8
repeat 2 times { count = count + 9 }
What is count at the end? -
39.🔁 repeat 5 times { repeat 6 times { beep } }
How many beeps are there? -
40.🔁 count = 10
repeat 4 times { count = count + 5 }
What is count at the end?
Answer key
- 16
- 16
- 71
- 4
- 10
- 80
- 20
- 82
- 30
- stores a value
- 21
- adds 1 to count
- 8
- 10
- 25
- 45
- 10
- 20
- 20
- 39
- 63
- 73
- 3
- 66
- 45
- 28
- 6
- 51
- 63
- 32
- 2
- 9
- 24
- 3
- 2
- 36
- 67
- 26
- 30
- 30
Free electronics lessons, practice and worksheets at talentjr.in/electronics-for-kids