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