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