C3. Coding
Specific Expectations
Coding Skills
C3.1
solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves sequential, concurrent, repeating, and nested events
- contexts:
- moving from one location to another horizontally and vertically
- creating shapes
- determining perimeter, using whole numbers and decimal tenths
- determining area, using whole numbers
- representing addition, subtraction, multiplication, and division of whole numbers
- representing addition and subtraction of decimal tenths
- testing equalities involving whole numbers
- verifying the commutative property for addition and multiplication of whole numbers
- verifying the associative property for addition of whole numbers
- creating repeating patterns
- creating growing patterns using a repeated operation
- code involving repeating events:
- code designed to create a square:
- code involving nested events:
- code designed to create a repeating pattern involving the rotation of a square:
- A loop is used to control a structure that allows for a sequence of instructions to be repeated.
- Loops make the code more readable and reduce the number of instructions that need to be written.
- Loops can be used to repeat steps or tasks that occur more than once in an algorithm or solution.
- Loops can exist within loops, referred to as “nested loops”.
Note
- Coding can support students in developing a deeper understanding of mathematical concepts.
- Coding can include a combination of pseudocode, block-based coding programs, and text-based coding programs.
- Students can program for various agents, such as a pixelated image on a screen, a classmate acting out the code when appropriate, or a physical device (e.g., robot, microcontroller) .
Have students describe what is happening in the following code:
Have students create their own repeating or growing pattern and the accompanying code.
Formulas are used in various contexts in mathematics, including to calculate the perimeter of a rectangle. Formulas can be expressed in words as well as using symbols. In coding, a formula may be a mixture of both words and symbols. Have students write code to determine the perimeter of a rectangle from user-inputted variables for the length and width of a rectangle. A possible example is shown below using pseudocode. This example could be programmed by students using either a text-based or a block-based programming language.
C3.2
read and alter existing code, including code that involves sequential, concurrent, repeating, and nested events, and describe how changes to the code affect the outcomes
- Code can be simplified by using loops or by combining steps and operations.
- Reading code is done to make a prediction about what the expected outcome will be. Based on that prediction, one can determine if the code needs to be altered prior to its execution.
- Code must sometimes be altered so that the expected outcome can be achieved.
- Code can be altered to be used for a new situation.
Note
- Using loops helps students organize their code and provides a foundation for considering efficiencies in program solutions.
- By manipulating conditions within a loop and the number of times the loop is repeated, students can determine the relationship between variables in lines of code and can explore math concepts, such as pattern intervals and terms.
Altering code can support students in developing a deeper understanding of mathematical concepts. Some alterations may make the code more efficient. Similarly, some calculations can be simplified, including when working with formulas and applying order of operations.
Have students alter the code (shown below) to determine the perimeter of a rectangle by simplifying the formula “perimeter = length + width + length + width”.
Have them execute the two programs to confirm that they both get the desired outcome. As a follow-up, have them alter the code so that it determines the perimeter of a square.
Provide students with code that generates a growing pattern involving dollar values (e.g., $5, $10, $15, …). Have them alter the code to generate the same growing pattern but expressed in cents (e.g., 500¢, 1000¢, 1500¢, …).
Provide students with code that creates a “flower” by using a repeating pattern that creates a square and rotates before creating another square. Have them alter the code to create a smaller or larger square, a smaller or larger angle of rotation, and finally a different repeating shape.