C3. Coding
Specific Expectations
Coding Skills
C3.1
solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves sequential events
- possible mathematical situations:
- moving from one location to another
- representing addition and subtraction of whole numbers
- engaging in patterning using actions and colours
- developing spatial reasoning
- code/instructions to model movement from one location to another:
- up 1, left 1, up 2, right 2, down 1, right 1:
- In coding, a sequential set of instructions is executed in order.
Note
- Coding can support students in developing a deeper understanding of mathematical concepts.
- Coding can include a combination of pseudocode, block-based coding programs, and text-based coding programs.
- Students can program for various agents such as a pixelated image on a screen, a classmate acting out the code when appropriate, or a physical device (e.g., robot, microcontroller).
- Students can decompose large problems into smaller tasks and develop sequential steps to accomplish each sub-task.
Before students begin to write code (or build code using printed materials and templates), provide them with opportunities to act out or model situations, such as “move 5 steps forward” on “action cards”, using manipulatives or their own body. This will help them visualize what they intend to make happen on the screen.
Present students with a situation such as a turtle wanting to lay its eggs in the sand and needing to get to a specific location while avoiding obstacles. Have students work with a partner, using assigned roles – one of them can be the “programmer” and the other the “agent” (e.g., robot). Mark spots on the floor with removable tape, indicating the starting point for the turtle and the obstacles (e.g., tree, rock, water). Have the programmer provide a sequence of instructions for the turtle to move in a certain horizontal or vertical direction for a certain number of steps.
For a mathematical situation that involves addition of whole numbers, have students create code to move a digital image horizontally or vertically across the screen for the number of steps that are identified in the addition expression.
For example, have students model 9 + 4 by coding a digital image to move 9 steps to the right and then an additional 4 steps to the right. To support them in developing their estimation skills, ask them to predict where the digital image will stop before they execute the code. To further their thinking, ask them to explain what happens if the second instruction says to move to the left instead of the right.
C3.2
read and alter existing code, including code that involves sequential events, and describe how changes to the code affect the outcomes
- alter the sequence of instructions and get to the same location on the stage:
- alter the sequence of instructions to follow a different path and get to the same location on the stage:
- alter the components of instructions and get to the same location on the stage:
- alter the components of instructions and do not get to the same location on the stage:
- Changing the sequence of instructions in code may produce the same outcome as the original sequence, but it may also produce a different outcome. It is important for students to understand when the order matters.
Note
- Similarly, for some mathematical concepts, the sequence of instructions does not matter, as illustrated by the commutative property of addition (e.g., 6 + 3 = 3 + 6). For other concepts, the order does matter; the commutative property does not work for subtraction (e.g., 6 − 3 is not the same as 3 − 6).
- Altering code can develop students’ understanding of mathematical concepts. Altering code is also a way of manipulating and controlling the outcomes of the code.
To support students in understanding the commutative property for addition, have them change the sequence of instructions in their code to model 4 + 9 instead of 9 + 4. Discuss why the digital image’s distance from the starting point remains the same in both cases.
When movement from one location to another involves moving in multiple directions, altering the sequence of instructions can change the result. For example, have students create code for the turtle to get to the pond. Then ask them to alter the sequence of instructions in their code and verify that the turtle can still get to the pond.