Coding with Nested Events and Subprograms
Grade 7 math worksheet · mathbonk.com/learn
Name: ______________________ Date: ____________
Look
| Shape drawn by a loop | Sides | Turn at each corner |
|---|---|---|
| Triangle | 3 | 120° |
| Square | 4 | 90° |
| Pentagon | 5 | |
| Hexagon | 6 |
- What turn at each corner draws a regular pentagon?
- What turn draws a regular hexagon?
- What shape does repeat 8 [move 10; turn 45] draw?
Practice
- repeat 4 [repeat 6 [stamp]]. How many stamps in all?
- repeat 5 [move 10; turn 72]. What shape is drawn?
- repeat 6 [move 10; turn ?]. What angle draws a regular hexagon?
- A subprogram called "square" runs 4 "move" blocks. It is called 8 times. How many moves in all?
- repeat 4 [move 5; turn 90]. What is the perimeter of the shape drawn?
- How many degrees are in a full turn?
- A regular octagon needs a turn of how many degrees at each corner?
- repeat 2 [repeat 10 [flip a coin]]. How many flips in all?
- A fair coin is flipped 100 times. About how many heads would you expect?
- Why use a subprogram instead of copying the same blocks five times?
- In repeat 2 [repeat 6 [stamp]; turn], which block runs exactly 2 times: stamp or turn?
Think it through
- Draw the shapes made by repeat 6 [move 10; turn 60] and by repeat 3 [move 10; turn 120].
- Explain why a subprogram makes code easier to fix.
Challenge
- repeat n [move 8; turn 40] draws a regular polygon. What is n, and what is the perimeter of the shape?
- A subprogram uses 10 blocks and is called 12 times. How many blocks run in total?