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