C3.1 Solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves the analysis of data in order to inform and communicate decisions.

Skill: Computational Problem Solving


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

In addition, the question "what will happen if…?" allows one to start a conversation about conditions and conditional statements. For example, in a probability problem, one might ask "what will happen if I roll a die 1,000 times?" or even "how many times will I get 2 by rolling a die 1,000 times?" Given the time required to perform this experiment manually, code becomes an efficient way to solve such a problem.

Skill: Representing Mathematical Situations Computationally


Coding can be used as a mathematical learning tool to represent and manipulate complex mathematical situations.

For example, in a spreadsheet, it is possible to represent a multi-step calculation with a single logical command. In this example, a multi-term addition is represented by the SUM command, followed by the cells to be added.

Skill: Writing Code


Writing and altering a code involves sequencing instructions in a specific order, following the syntax of a programming language. Writing code can be similar to writing text. Pseudocode is writing the instructions for a code in no particular program language.

For example, conditional cell formatting in a spreadsheet requires a few lines of code, but can make data analysis or outlier identification very easy and efficient. In this example, we see two conditions for the color of cells D12 through D15 in a spreadsheet.

Note: To capture the conditional formatting, right click on the cell and choose "conditional formatting"

We could also represent this situation with pseudocode, that is:

For D12:D15

IF (value) < 20 OR (value) = 20

THEN color = GREEN

IF NOT color = RED

Skill: Executing Code


Execution of code is when the code is read and compiled by the coding program and is referred to as the output. In block coding, the execution of a code is often done by means of a button in the interface, while text-based programming languages require precise compilation program that essentially translates the code from the programming language to the machine language (for example, binary code) so that it can execute the code. This also applies to robotic devices.

Some examples of run buttons for block-based coding program

Skill: Analyzing Data Using Code


In order to make good decisions, you need good data. Coding programs and microcontrollers (Arduino, Micro:bit, etc.) can automate the collection and analysis of data, which can support informed decision-making and provides a basis for valid arguments. Data entry can be done in several ways; for example, code could be written to enable data collection through a form that compiles the data into a spreadsheet. Most spreadsheets accept codes to facilitate data analysis.

Raw data can be turned into a relative-frequency table, and conditional formatting can be applied to cells to highlight specific data or trends.

Note: To capture the conditional formatting, right click on the cell and choose "conditional formatting"

Sensors take it one step further. Many microcontrollers have sensors installed or plugged in that allow for data collection. These microcontrollers can be found everywhere in a student's daily life - the smart thermostat that acts as a switch that activates the ventilation system when a temperature is reached, or the accelerometer on a smartphone or smartwatch that determines the number of steps a person takes in a day to determine the distance traveled. Discussions about the ways in which data is collected and analyzed through coding will allow the student to further explore the limits of what is possible to accomplish with code.

Knowledge: Events and Structures (Prior Knowledge)


Sequential Events

A set of instructions executed one after the other.

Example

Simultaneous Events

Several events that occur at the same time, also called “concurrent” events.

Example

Recurring Events

Repeating events. In coding activities, loops are used in code to repeat instructions.

Example

Nested Events

Control structures placed inside other control structures. For example, loops occurring inside loops or a conditional statement being evaluated inside a loop.

Example

Conditional Statements

A conditional statement is a type of coding command that instructs the program to compare values and expressions and then make decisions based on whether the condition is true or false.

Conditional statements are first present when the execution of an event or a sequence of code depends on the achievement of a specific condition. Boolean values (true or false) are often used and associated with terms such as if, else, until and when.

Example

Code Efficiency

Writing functional code using a minimum of blocks or commands.

Example

Subprograms

A small set of instructions that performs a simple task. Subprograms can be combined in a main program to accomplish a large task using simple steps.

Example

To insert the rectangle, simply add the new "rectangle" block to the code, and specify the base and height values.

Defined Count

Number of times instructions are repeated based on a predefined value or until a condition is met.

Example