# MATH + CODING WORKSHOP 3-4

Designed to serve as a base lesson plan for diverse learning settings (f2f, hybrid, online, parents/children).

Although designed with the Ontario 3-4 math curriculum in mind, this workshop would be of value to all educators interested in learning how to integrate math + coding.

Based on Understanding Math + Coding, 1-9.

## A. WALKING SQUARES

#### 1. HANDS-ON

Engage students in giving and following explicit instructions for walking a square path. This can be modelled physically as well as with chart paper and markers, to provide physical and visual anchors for understanding shapes, as well as code.

#### 2. How to walk a square

1. walk forward
2. turn right
3. walk forward
4. turn right
5. walk forward
6. turn right
7. walk forward
8. turn right

Follow the above instructions as a simple robot might:

1. walk forward until you come to a classroom wall
2. turn right and keep turning right
3. say: “Help! Help!” or “Error! Does not compute! Error!”

How can we make the instructions more clear?

• walk 4 steps
• make a quarter turn, to the right
• walk 4 steps
• make a quarter turn, to the right

## B. BUG WALKS WITH CODE

#### 1. Bug walks a square

A. Walk a square using the code at scratch.mit.edu/projects/421870005/editor

• Click ERASE to clear and reset.
• Click WALK until BUG walks a square.

B. Draw another square:

• Grab and drag BUG to a different location on the stage.
• Click on COLOUR to change the colour of the pen.
• Click WALK until BUG walks a second square.

C. Edit the WALK code as shown below. Then execute the code.

#### 2. Bug walks a pattern of squares

A. Walk a pattern of squares with the code at scratch.mit.edu/projects/421900037/editor

• Click on ERASE.
• Click on WALK + TURN.

B. Draw more squares.

• Click on WALK + TURN a few more times.
• What do you observe?
• How does the code make this happen?

#### 3. Bug walks squares with “nested repeat”

A. This code uses a “nested repeat” (a repeat within a repeat): scratch.mit.edu/projects/421910828/editor

B. Edit the code to create new math art.

## C. BUG WALKS WITH A VARIABLE

#### 1. Hands-on

A. How might you engage students to experience the walk pattern below, before using coding?

B. What “instructions” might students give for creating the walk pattern?

C. What are the underlying math concepts?

#### 2. A coding puzzle

A. Earlier, we used a repeat structure to more efficiently write the code for walking a square.

• How do we edit this code so that the length of side (number of steps) increases after each repetition?

#### 3. “Steps” with a variable

A. Run this code to see how it solves the coding puzzle in #2 above: scratch.mit.edu/projects/474587945/editor

• How is this code different from the code in #2 above?
• Why?

#### 4. “Angle” with a variable

A. This code also uses a variable for the angle: scratch.mit.edu/projects/511214538/editor

• Execute the code to see wha it does.
• Edit the code to create new math art.