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