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