C3.1 Solve problems and create computational representations of mathematical situations by writing and executing efficient code, including code that involves conditional statements and other control structures.
Activity 1: Perimeter and Area
The student will create a program that determines the area and perimeter of a geometric shape using measurement. They will:
- determine the appropriate commands or blocks to represent the area or perimeter formula with code;
Example
Use "operator" blocks to represent operations in calculations.
![Blocks of code:Variable block stating, “set area to base, multiplied, height”.Variable block “set perimeter to ‘2’, multiplied, base, plus 2, multiplied, height.”](/img/activite/algebre/en/6e/VE6_Algebre_Image206_en.png)
Note: There is more than one possible representation of a formula; for example, the perimeter could be expressed with the following blocks:
![Blocks of code:Variable block “set perimeter to ‘2’, multiplied, base, plus 2, multiplied, height.”](/img/activite/algebre/en/6e/VE6_Algebre_Image207_en.png)
- ensure that the data is provided by the user.
Example
Use the "ask" block to define variables.
![Blocks of code:Sensing block stating, “ask ‘question’ and wait”.Variables block stating, “set my variable to motions block stating, “answer”.](/img/activite/algebre/en/6e/VE6_Algebre_Image208_en.png)
A code that makes this task happen might look like this:
![](/img/activite/algebre/en/6e/VE6_Algebre_Image209_en.png)
Source : Scratch.
Activity 2: Budget
The student will be required to use spreadsheet software to automatically account for a series of expenses.
They will need to use commands such as "SUM" and "MINUS" to make automatic calculations when data is entered in a cell range.
They may also use conditional formatting to distinguish expenses (credit, cash, check, etc.) or to determine whether or not the sum of the expenses is within a budget.
For example, the student uses a spreadsheet to organize a lemonade sales business, collect data during a week of sales, and use measures of central tendency to make predictions about future sales.
Spreadsheet example (showing formulas)
![Screen shot of an electronic spreadsheet. On the right, a column of numbers from one to 22. At the top, horizontally, letters from 'A' to 'F'. Some cells are filled with information such as: item, cost, adjusted cost, notes...](/img/activite/algebre/en/6e/VE6_Algebre_Image215_en.png)
![Formatting rules:Green square marked 123: value is greater than 20.Yellow square marked 123: value is between 10 and 20.Pink square marked 123: value is less than 10.](/img/activite/algebre/en/6e/VE6_Algebre_Image216_en.png)
Note: The spreadsheet recognizes the formula "=SUM".
Example of the table (showing values)
![Screen shot of an electronic spreadsheet. On the right, a column of numbers from one to 22. At the top, horizontally, letters from 'A' to 'F'. Some cells are filled with information such as: item, cost, adjusted cost, notes...](/img/activite/algebre/en/6e/VE6_Algebre_Image217_en.png)