Math Bonk! Learning Centre Play the game

Worksheet for the lesson Coding with Nested Events · All worksheets

Coding with Nested Events

Grade 6 math worksheet · mathbonk.com/learn

Name: ______________________   Date: ____________

Look

A grid of stamps that is 5 rows tall and 5 columns wide, with arrows showing an outer loop and an inner loopinner loop: 5 timesouter loop: 5 times
  1. repeat 5 [repeat 5 [stamp]] makes this grid. How many stamps in all?
  2. The inner loop is changed to repeat 4. How many stamps now?
  3. Both loops are changed to 6. How many stamps now?

Practice

  1. How many stamps does repeat 2 [ repeat 7 [ stamp ] ] make?
  2. How many stamps does repeat 5 [ repeat 2 [ stamp ] ] make?
  3. A program says repeat 2 [ repeat 6 [ print a star ]; new line ]. How many lines are printed?
  4. In that program, how many stars are on each line?
  5. Write shorter code for 15 stamps in a row.
  6. How many stamps does repeat 4 [ move 10; stamp ] make?
  7. True or false: a nested loop is a loop inside another loop.
  8. A program says repeat 3 [ repeat 3 [ stamp ]; turn 90 ]. How many turns happen?
  9. Rewrite this with a loop: forward 5, forward 5, forward 5.
  10. Two sprites move at the same time. What kind of event is that?
  11. A stamp program makes 5 rows with 6 stamps in each row. How many stamps in total?
  12. To make a stamped picture taller, which loop's count do you change?

Think it through

  1. Draw the grid of stamps made by repeat 3 [repeat 4 [stamp]].
  2. Explain the difference between the outer and the inner loop.

Challenge

  1. How many stamps come from repeat 6 [repeat 7 [stamp]]?
  2. A program is repeat 2 [repeat 3 [stamp]; new line]. Rewrite it so that it prints 4 lines.

Answer key

Look

  1. 25
  2. 20
  3. 36

Practice

  1. 14
  2. 10
  3. 2
  4. 6
  5. repeat 15 [ stamp ]
  6. 4
  7. True
  8. 3
  9. repeat 3 [ forward 5 ]
  10. concurrent events
  11. 30
  12. the outer loop

Think it through

  1. 3 rows of 4 stamps
  2. The inner loop runs completely each time the outer loop runs once

Challenge

  1. 42
  2. repeat 4 [repeat 3 [stamp]; new line]