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.”

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.”
  • 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”.

A code that makes this task happen might look like this:

A block of code starting with a green flag event bloc stating, when clicked.A sensing block stating, ask how long is the base of the rectangle? And wait.A variables block stating, set base to answer.A sensing block stating, ask what is the height of the rectangle? And wait.A variables block stating, set height to answer.A looks block stating, press “a” to get the area. Press “p” get the perimeter.A forever control block with the following blocks embedded inside.A control block stating, if key a pressed? ThenTwo embedded blocks as follows.A variable block stating, set area to base times height.A looks block stating, say join “The area is” joined with the variable area and the text square units.The else portion of the if control block contains the following.A control block stating, if “p2 pressed then.Two blocks of code are embedded within this control block.A variable block stating, set perimeter to 2 times base plus 2 times height.A looks block stating, join “The perimeter is” with another join block stating, perimeter, units.

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...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.

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...