← Loops and variables lesson New set →

Electronics Worksheet: Loops and Variables

Electronics lesson 25: Loops and variables · Set 63 · 40 questions
TalentJR

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

Answer key

  1. 12
  2. 6
  3. 48
  4. stores a value
  5. 78
  6. 32
  7. 3
  8. 66
  9. 12
  10. 48
  11. 4
  12. 16
  13. 36
  14. 5
  15. 6
  16. 62
  17. 6
  18. adds 1 to count
  19. 10
  20. 6
  21. 7
  22. 32
  23. 45
  24. 42
  25. 36
  26. 42
  27. 16
  28. 24
  29. 17
  30. 4
  31. 3
  32. 27
  33. 28
  34. 8
  35. 55
  36. 67
  37. 8
  38. 20
  39. 128
  40. 13

Free electronics lessons, practice and worksheets at talentjr.in/electronics-for-kids