C3.1 Solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves sequential events.

Skill: Solving Problems Using Computational Methods


Coding can be used to automate tasks and visualize mathematics, making it easier to solve problems. By its very nature, coding lends itself well to trial and error, giving students the opportunity to solve problems by learning from their mistakes. Therefore, they can use the questioning "What will happen if…?".

For example, the student could use the code to show the position of a sprite in relation to elements in a background.

Image of a frog in its inital position before any movements.

In this example, the student will need to create a code pattern to represent the position of the frog in relation to the small mushrooms. This also helps practice relative vocabulary(in front, behind, under, over, left, right, etc.).

Ability to Represent Mathematical Situations Computationally


Coding can be used as a representational tool in the same way as manipulatives. By using written blocks or commands, very complex mathematical situations can be modelled and manipulated visually, which can make very abstract concepts concrete.

For example, the student could determine the movements required to "get to 10". Here is a pattern of 10 moves:

A coding line: frog, start on green flag, move right 3 times, move up 3 times, move right 3 times, move down one time, end.

This pattern represents a move of three blocks to the right, three blocks up, three blocks to the right and one block down. This could be represented by the operation \(3 + 3 + 3 +1 = 10\). The student could also use algebraic thinking to group similar moves together to make \(6 + 3 + 1 = 10\). The move down could also represent a subtraction, hence the representation of (3 + 3 + 3 - 1 = 8). It is therefore possible to use the same code pattern to represent several mathematical situations.

Skill: Writing Code


Writing or editing a code consists of putting instructions in a specific order according to the syntax of a programming language. Writing code can be similar to writing text, just as pseudocode is writing instructions for code in the familiar language. Block coding can make it easier to follow the syntax by using different block shapes and colours.

For example, the pseudocode below describes a sprite that will move to a specific location.

sprite - frog

Start condition = true (green flag)

Move

1 square to the right

Move

1 square to the right

Move

1 square to the right

Move

1 square up

Move

1 square up

End

This pseudocode can act as the planning or prewriting step. The resulting code might look like this:

A coding line: frog, move right 3 times, move up 2 times.

Skill: Executing Code


Code execution is the step in which the code pattern is read and compiled by the computer. It is at this stage that a functional code will give the desired result, or output (and a non-functional code will give a different output or no output). In block coding, code execution is often done by means of a button in the interface, while some robotic devices require specific compilation software that essentially translates the code from the programming language to the robot language.

Here are some examples of run buttons for block coding software:

Examples of coding execution button.

Source: Microbit.

Examples of coding execution button.

Source : Scratch.

Knowledge: Sequential Events


A set of instructions executed one after the other, usually from top to bottom or from left to right on a screen.

For example, in the map of a fictitious city like the one shown below, one could create a pseudo-code of sequential events in order to get from one building to another

Cartographic image of a village.

Initial position = to the left of the yellow house

Starting condition = true

Move 5 steps

Direction = bottom ↓

Move 2 steps

Direction = right →

Final position = in front of the police station

The code corresponding to this pseudocode, as programmed in block coding software, might look like this:

Coding line:
Start on green flag, move down one time 5 times, move right one time 2 times.