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