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