Browse all quizzes
ProgrammingGrade 4en

πŸ” Loops and Repeating Events

In this quiz, you'll explore how loops help us write simpler code by repeating actions instead of writing the same steps over and over. You'll learn to trace code with loops, spot when a loop will stop, and understand how loop variables change each time around. This quiz builds your computational thinking skills for Grade 4 Mathematics. **What you'll learn:** - How to read and trace loops to predict how many times they repeat - When to use a loop instead of writing code multiple times - How loop variables and conditions control when a loop stops - Basic patterns like counting loops and nested loops

18 questions Β· play in your browser
No signup required β€” try it for free.

Questions in this quiz

Answers hidden β€” play to find out.

  1. Question 1

    Look at the following code. How many times will the word 'Hello' be printed?

    for i = 1 to 5 do print 'Hello' end

  2. Question 2

    A loop is useful when you need to repeat the same code many times.

  3. Question 3

    Which of these loops will repeat exactly 3 times?

  4. Question 4

    Look at the following code. What will be printed?

    count = 1 while count ≀ 3 do print count count = count + 1 end

  5. Question 5

    When you write a for-loop from 1 to 10, it will always run exactly 10 times.

  6. Question 6

    You want to print the numbers 2, 4, 6, 8, 10. Which loop would work best?

  7. Question 7

    Look at the following code. How many stars will be printed?

    for row = 1 to 3 do for col = 1 to 4 do print '*' end end

  8. Question 8

    A while loop must have a condition that eventually becomes false, or it will loop forever.

  9. Question 9

    What is wrong with this code?

    while x > 0 do print 'Hello' end

  10. Question 10

    You need to print the numbers 10, 9, 8, 7, 6, 5. Which loop would you use?

  11. Question 11

    Look at the following code. What is the value of 'sum' after the loop ends?

    sum = 0 for i = 1 to 4 do sum = sum + i end

  12. Question 12

    If a loop's condition is 'while x < 10' and x starts at 1, the loop will stop when x reaches 10.

  13. Question 13

    Why would you use a loop instead of writing the same code line many times by hand?

  14. Question 14

    Look at the following code. What does it do?

    for i = 1 to 5 do print i * 2 end

  15. Question 15

    A for-loop is better than a while loop for counting from 1 to 100.

  16. Question 16

    Look at the following code. When does the loop stop?

    x = 5 while x > 0 do print x x = x - 1 end

  17. Question 17

    Which code would print 'Done' only once after the loop finishes?

    A) for i = 1 to 3 do print 'Done' end

    B) for i = 1 to 3 do print 'A' end print 'Done'

  18. Question 18

    Look at the following code. What number will be printed last?

    for i = 10 to 15 do print i end