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.🔁 repeat 4 times { repeat 5 times { beep } }
How many beeps are there? - 2.🔁 What does a variable do in a program? (a) blinks an LED (b) joins two wires (c) stores a value (d) measures light
-
3.🔁 repeat 6 times { repeat 5 times { beep } }
How many beeps are there? - 4.🔁 What does “count = count + 1” do? (a) sets count to 1 (b) takes 1 away (c) prints 1 (d) adds 1 to count
-
5.🔁 repeat 4 times { repeat 6 times { beep } }
How many beeps are there? -
6.🔁 count = 7
repeat 4 times { count = count + 5 }
What is count at the end? -
7.🔁 x = 2
repeat 2 times { x = x × 2 }
What is x at the end? -
8.🔁 repeat 4 times { repeat 2 times { beep } }
How many beeps are there? -
9.🔁 count = 3
repeat 6 times { count = count + 9 }
What is count at the end? -
10.🔁 count = 1
while (count < 29) { count = count + 4 }
How many times does the loop run? -
11.🔁 count = 4
while (count < 12) { count = count + 4 }
How many times does the loop run? -
12.🔁 x = 1
repeat 4 times { x = x × 2 }
What is x at the end? -
13.🔁 total = 0
for i = 1 to 7 { total = total + i }
What is total at the end? -
14.🔁 x = 1
repeat 5 times { x = x × 2 }
What is x at the end? -
15.🔁 count = 3
while (count < 35) { count = count + 4 }
How many times does the loop run? -
16.🔁 repeat 5 times { repeat 3 times { beep } }
How many beeps are there? -
17.🔁 count = 4
repeat 5 times { count = count + 3 }
What is count at the end? -
18.🔁 x = 3
repeat 2 times { x = x × 2 }
What is x at the end? -
19.🔁 count = 1
while (count < 13) { count = count + 2 }
How many times does the loop run? -
20.🔁 count = 0
while (count < 21) { count = count + 3 }
How many times does the loop run? -
21.🔁 count = 3
repeat 9 times { count = count + 8 }
What is count at the end? -
22.🔁 x = 2
repeat 3 times { x = x × 2 }
What is x at the end? -
23.🔁 total = 0
for i = 1 to 6 { total = total + i }
What is total at the end? -
24.🔁 count = 2
while (count < 42) { count = count + 5 }
How many times does the loop run? -
25.🔁 x = 3
repeat 5 times { x = x × 2 }
What is x at the end? -
26.🔁 repeat 2 times { repeat 2 times { beep } }
How many beeps are there? -
27.🔁 total = 0
for i = 1 to 12 { total = total + i }
What is total at the end? -
28.🔁 repeat 5 times { repeat 4 times { beep } }
How many beeps are there? -
29.🔁 x = 4
repeat 2 times { x = x × 2 }
What is x at the end? -
30.🔁 count = 5
while (count < 9) { count = count + 2 }
How many times does the loop run? -
31.🔁 repeat 5 times { repeat 2 times { beep } }
How many beeps are there? -
32.🔁 count = 5
while (count < 25) { count = count + 5 }
How many times does the loop run? -
33.🔁 total = 0
for i = 1 to 9 { total = total + i }
What is total at the end? -
34.🔁 count = 1
repeat 7 times { count = count + 3 }
What is count at the end? -
35.🔁 count = 3
while (count < 17) { count = count + 2 }
How many times does the loop run? -
36.🔁 x = 5
repeat 5 times { x = x × 2 }
What is x at the end? -
37.🔁 count = 5
repeat 5 times { count = count + 4 }
What is count at the end? -
38.🔁 repeat 3 times { repeat 3 times { beep } }
How many beeps are there? -
39.🔁 x = 1
repeat 3 times { x = x × 2 }
What is x at the end? -
40.🔁 repeat 2 times { repeat 5 times { beep } }
How many beeps are there?
Answer key
- 20
- stores a value
- 30
- adds 1 to count
- 24
- 27
- 8
- 8
- 57
- 7
- 2
- 16
- 28
- 32
- 8
- 15
- 19
- 12
- 6
- 7
- 75
- 16
- 21
- 8
- 96
- 4
- 78
- 20
- 16
- 2
- 10
- 4
- 45
- 22
- 7
- 160
- 25
- 9
- 8
- 10
Free electronics lessons, practice and worksheets at talentjr.in/electronics-for-kids