# 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

(a) Here is one way to walk a square. Ask students: “Would this work?”

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

(b) Follow the above instructions as a 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!”

(c) Ask students: “How might we make the instructions more explicit?” Students may suggest:

• 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

1. Go to https://scratch.mit.edu/projects/421870005/editor to see the code below.

2. Run the ERASE code, and then run the WALK code, by clicking on each.

3. Keep running the WALK code until Bug walks a square.

4. Click/drag Bug to a different place on the Stage.

5. Change “move 100 steps” to “move 50 steps.

6. Run the WALK code until Bug walks another square.

7. Click the COLOUR code. Move Bug to a different place on the Stage. Run the WALK code until Bug walks a new square.

8. Play with ERASE, WALK and COLOUR to create math art on the Stage.

9. Explain the the meaning of each of the code blocks used.

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

1. Got to https://scratch.mit.edu/projects/421881362/editor to see the code below.

2. Run the code in this sequence: ERASE, WALK, TURN, WALK, TURN …

3. How many times do you have to repeat WALK + TURN to complete the pattern? Why?

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

1. Go to https://scratch.mit.edu/projects/421900037/editor to see the code below.

2. Predict what the code does.

3. Run the code to test your prediction.

4. How is this code similar to, and different from, the previous code?

5. Explain the meaning of each of the code blocks used.

6. Edit the code to get the pattern below.

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

1. Go to https://scratch.mit.edu/projects/421910828/editor and Run the code.

2. Describe the meaning of “nested repeat”.

3. Add the block below to the code, as shown on the right. Predict how the output would change.

4. Run the code to test your prediction.

5. Edit the code to create new math art.

## C. BUG WALKS WITH A VARIABLE

#### 1. Hands-on

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

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

3. What are the underlying math concepts?

#### 2. A coding puzzle

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

2. Why is it more of a challenge to use a repeat structure to more efficiently write the code for walking a spiral? What is different?

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

1. Go to https://scratch.mit.edu/projects/474587945/editor. This code uses a variable called “steps” that we can increase within the repeat structure.

2. Run the ERASE code and the WALK + TURN code to see the output.

3. Change turn 90 degrees to:

4. Run the ERASE code and the WALK + TURN code to see the output.

5. Edit the code to get these patterns:

a)

b)

c)

4. Edit the code to create new patterns.

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

2. Edit the code as follows:

• In the left menu (shown at right), select Variables, then select Make a Variable.
• Name the variable “angle”
• Edit the code as shown below.
• The output should look as shown below (colours may vary).