solve problems and create computational representations of mathematical situations using coding concepts and skills
solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves sequential, concurrent, repeating, and nested events
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.
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
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.