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 trying different things. Therefore, they can use the questioning "What will happen if…?".

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

In this example, the students could create a code that moves the frog two steps backwards towards the small mushrooms and then test it to see if the code brings the frog to the mushrooms. This also helps practice positional vocabulary (in front, behind, under, over, left, right, etc.).

Skill: Representing 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 students could determine the movements required to "get to a total of 10 moves". Here is a pattern of 10 moves:

This pattern represents a move of three blocks to the right, three blocks up, three blocks to the right and one block down for a total of 10 moves. 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 code consists of putting instructions in a specific order using the syntax of a programming language. Writing code can be similar to writing text, just as pseudocode is writing instructions for code in familiar language. Block coding can make it easier to follow the syntax because it uses different block shapes and colours for different actions.

For example, the pseudocode below describes how a sprite 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:

Skill: Executing Code


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

Examples of run buttons for block coding software include:

Source: Microbit.

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 pseudocode of sequential events in order to get from one building to another:

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 pseudocode could be programmed in block coding software as: