← Loops and variables lesson New set β†’

Electronics Worksheet: Loops and Variables

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

Answer key

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

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