C3. Coding

Solve problems and create computational representations of mathematical situations using coding concepts and skills.

Learning Situation: An Obstacle Course


Duration: 75 minutes

Summary

In this learning situation, the student reads, alters and writes code to navigate a sprite through an obstacle course. The student also describes the relative position of an object and the movements required to move from one object to another when creating the obstacle course.

This learning situation requires a coding program.

Overall Expectations Specific Expectations
C3. Coding
Solve problems and create computational representations of mathematical situations using coding concepts and skills.
C3.1 Solve problems and create representations of mathematical situations computationally by writing and executing code, including code that includes sequential events and concurrent events.

C3.2 Read and alter existing code, including code that involves sequential and concurrent events, and describe how changes to the code affect the outcomes.

E1. Describe and represent shape, location, and movement by applying geometric properties and spatial relationships in order to navigate the world around them. E1.5 Describe the relative position of several objects and the movements required to move from one object to another.

High-Impact Instructional Practices in Mathematics Description
Mathematical Conversations At the time of the simulation, a mathematical conversation is initiated with the students in the class. This conversation will encourage them to share their ideas with others, to show their understanding related to the relative position of an object and displacement, to reason and to prove their reasoning. Students will be able to make connections to real-life experiences and communicate their knowledge related to the topic at hand. Evidence can be collected to guide instruction.
Flexible Groupings Working in pairs when writing and altering codes encourages communication and collaboration, among other things. Flexible groupings can foster collaboration and give students the opportunity to engage in rich mathematical conversations, learn from each other, and advance their mathematical thinking. Groupings can be random, heterogeneous or homogeneous, depending on the needs of the students.
Teaching in Small Groups Small group teaching is an instructional practice aimed at advancing student learning. Throughout the writing and alteration of code, it is important to circulate among the groups of students in order to provide them with the necessary spontaneous support according to what is observed and heard. Teaching in small groups provides an opportunity to review mathematical concepts with students that support their new learning. These students are therefore able to deepen their understanding of the concepts under study (position and translation or coding).
Direct Instruction When a code does not produce the expected result, teachers may ask students to explain it. The teacher can then use the moment to provide explicit instruction related to the observed difficulty. This instruction provides an opportunity to check students' understanding and provide immediate feedback.

Prior Learning

It would be better if students have the opportunity to explore the coding program to be used in order to become familiar with its interface and basic elements. However, this learning situation can also serve as an initial exploration of a coding program by allocating more time, so that the students become familiar with it in the process.

Achievement Chart Categories Criteria

Skills Success Criteria
Knowledge and Understanding
  • The student knows the appearance and function of blocks in the coding program used.
  • The student describes moving from one object to another with reference to direction and number of moves.
  • The student determines the blocks and actions of each block used in sequential and concurrent events.
  • The student understands what two sets of simultaneous instructions represent.
Thinking
  • The student plans the location and duration of a "pause" block to properly synchronize concurrent events in their code.
  • The student predicts the outcome and alters code to achieve a specific goal.
  • The student demonstrates an understanding of the difference between sequential and simultaneous events in the context of coding.
  • The student alters code and determines the effect on its outcome.
Communication
  • The student explains the code sequence using appropriate terminology (left, right, up, down, etc.).
  • The student uses vocabulary related to the relative position of an object (above, below, on, under, beside, inside, outside, right, left).
Application
  • The student puts the blocks in the right places and in the right order to create patterns that contain simultaneous events.

Learning Goals

At the end of this learning task, the student will be able to:

  • use terminology specific to the relative position of an object (above, below, on, under, beside, inside, outside, right, left) and coding (sprite, sequential events, simultaneous events);
  • describe the movements of a sprite (to the right, to the left, up, down);
  • write code that has more than one sprite moving at the same time;
  • read code, and alter it to make it more efficient.

Materials

  • block program appropriate to the student's ability
  • graph paper and pencils (optional)

Note: The examples in this learning situation were created using Scratch Jr.

Mathematical Vocabulary

code, sprite, sequential events, simultaneous events, left, right, above, below, in front of, behind, displacements (x units to the left, to the right, up, down).

Before Learning (Warm Up)

Duration: 10 minutes

Assessment can be carried out through…

Show students the picture below. Ask them the question, "What do you notice?" Use the Think-Pair-Share strategy to initiate a mathematical conversation with students.

Think

Require at least one minute of silent reflection. This ensures that students think without the pressure of time or the influence of others' answers.

Pair

Ask students to find a partner to discuss their first impressions of the photo.

Share

Open the conversation. First, invite the students to express their impressions of the photo as well as their observations following their conversation with their partner. Then try to direct the questioning towards the mathematical concepts to be studied.

Questions to ask and possible responses from students:

  • What are the children doing? What is this type of activity called?
    • An obstacle course.
  • Can you describe the obstacle course for me? What do you see?
    • A child jumps over a rope.
    • There is a tunnel behind the rope. It is to the left of the two children standing back. There are flags tied to the trees, above the children.
  • How many children are racing?
    • Three children are racing.
    • One child is racing and the other two are waiting their turn.
  • How can we determine who will win?
    • Time the children to determine who completed the race the fastest.
    • Have the children race at the same time. Whoever completes the obstacle course first is the winner.

Active Learning (Explore)

Duration: 50 minutes in addition to the time allotted to explore the coding software, as needed

Assessment can be carried out through…

Introduce students to code, such as the one below.

Ask students to find a partner. Have them read the code together to describe the movement of the butterfly. When students are satisfied with their answers, have them read the code for the bird.

Facilitate a class discussion that compares the two codes.

Sample Questions Responses:

  • Which travels the farthest, the butterfly or the bird?
    • The butterfly travels the farthest, because it moves 6 squares to the right, while the bird moves only 4 squares to the right.
    • The bird travels the farthest, because it moves 4 squares up, while the butterfly moves one square up, and then one square down.
  • Will the bird or the butterfly complete their move first?
    • Both will complete at the same time, because they each have 8 blocks in their code.
    • The bird will finish first because it only has 4 move blocks to the right.
  • What does the green flag mean?
    • This is the starting signal.

Have students recreate the code using the block coding program and have them check their answers to the above questions.

After allot students time to explore with the coding program in order to alter the code and observe the changes in the behaviour of the butterfly and the bird. Students may add or omit blocks of code to see the effect.

Possible Observations Possible Interventions
The student recreated code does not look like the code that was shown. Ask the student to explain the blocks of code and its effect on the outcome.

Provide the student with a hard copy of the code to be duplicated so that they can compare it with their code.

The student's code includes logic errors (the code does not give the desired result). Provide the student with a sheet of grid paper so that they can trace the movements and determine the blocks causing the error (this looks like pseudocode).

Suggest that the student share their code with another student who could read it over and give them hints on how to solve it (similar to revision in the writing process).

Student code includes syntax errors (code does not work at all). Review with the student the initial situations (for example, the green flag).

Ask the student to check if the blocks of their code are well connected.

Provide students the following new scenario for writing code. An obstacle course must be created, in which two sprites compete, much like the butterfly and the bird. The students choose the two sprites as well as the obstacles of the race and describe the movements of the sprites related to the obstacles. One of the sprites will have to reach the finish line before the other.

Possible Answer

Path: The butterflies will have to fly over the chair, under the table, touch the purple pencil holder and fly around the globe to finish in front of it. The winning butterfly will be the one who shouts "I'm done!" first.

Possible yellow butterfly code:

Possible purple butterfly code:

Note: It is important to encourage students to run their code often. A large portion of learning can be done through trial and error.

Possible Observations Possible Interventions
The student does not know where to start. Have the student choose the obstacles for the race from the sprite menu, then determine the route.

Provide the student with physical materials with which to construct a representation of his or her obstacle course in order to have a visual cue before beginning to code.

Ask the student to write, on paper, a pseudocode, that is to say a description or a drawing of their obstacle course. Grid paper could be used.

The student does not deviate at all from the code provided at the beginning of the activity. Ask the student to describe the path of the obstacle course. Do the movements of the sprites reflect the race? How can the movements be made more realistic?

Encourage the student to alter the blocks of code, one at a time, and execute the change in order to see the effect on the behaviour of the sprites.

The student creates two identical codes for his two sprites Note: It is very common for the student to create two identical codes for their two sprites when talking about simultaneous events, as they sometimes imply that both sprites must do the same thing at the same time.

Ask the student if it is possible to determine which is the winning sprite when the two codes are identical.

Use the example of another kind of race to activate the student's prior knowledge. How do you know when a race has started? A green light, a gun, a sound? Once the race has started, do the sprites move exactly the same way?

Note: Many coding programs allow students to record their voice, so students can create a narrative for the race or communicate their thinking.

Example of a block allowing voice recording in ScratchJr.

Consolidation (Learning)

Duration: 15 minutes

Assessment can be carried out through…

  • Ask for volunteers or strategically select student-generated codes that emphasize the learning goals regarding relative movements and positions of objects and simultaneous events.
  • Have the selected teams present their code to the class. Ask the team to explain the code and rules of their obstacle course (what moves to make and how to win). Instruct the presenting team to not tell the class who wins the race. For each presentation, have the class read the presented code and make a prediction as to who will win the race. Lastly, have the presenting team execute their code to show the class which sprite wins.
  • Sample Discussion questions:
    • How do we make sure that both sets of code start at the same time? (By clicking on the green flag)
    • What would happen if you clicked on each sprite to execute the code? (You would have to move the mouse pointer from one sprite to another to activate them, so it would be impossible to activate them all at the same time)

Example of a block allowing to start a sequence by clicking the sprite.

  • In this case, are the events still simultaneous? (Even if the two codes are not executed at the same time, there are times when both sprites move at the same time. They are simultaneous events at those times)

Next Steps

Robotics is a great way to consolidate learning in coding. A race in which a robot, such as Sphero, Ozobot, LEGO, or other, competes with another robot with a different code could make the concept of simultaneous events even clearer to students.

Unplugged Option

If access to the material is limited to computer-based platforms, it would be possible to emphasize simultaneous events by asking students to move sprites in diagonal paths (for example, to draw a triangle). Diagonal movement requires a horizontal movement and a vertical movement simultaneously, because there is no specific block for this kind of movement. The diagonal move is more time efficient than a horizontal move followed by a vertical move, even if the end position is the same. This could make eventual “obstacle races” more interesting.

Connections with Other Mathematical Strands (Sequential Events)

Number

B1.5 Describe what makes a number even or odd.

By using an unknown quantity of sprites, the student can write a sequence of codes allowing the sprites to be placed, two by two (simultaneously), in an organized manner, on the screen. The student can determine whether the number of sprites is even or odd by observing whether or not there are any left after pairing.

B2.6 Represent division of up to 12 items as the equal sharing of a quantity, and solve related problems, using various tools and drawings.

Using a number of sprites from 1 to 12, the student can write code in which the objects move into equal groups; for example, if there are 6 sprites on the screen and the goal is to create 3 equal groups, they creates code so that 3 sprites move simultaneously to three different regions of the screen, then does the same for the other three sprites to create 3 groups of 2 sprites.

Spatial Sense

E1.5 Describe the relative positions of several objects and the movements needed to get from one object to another.

The student can write a pattern of codes so that a sprite moves on a map. Diagonal movements require simultaneous events, that is, a horizontal movement at the same time as a vertical movement.

Differentiated Instruction and Universal Design for Learning

  • A checklist of the blocks and their function or the colour code used by the coding program could be useful for students who are beginners.
  • The individual task of coding an obstacle course could be a team task of two or three (avoid teams of more than three to encourage participation by all students).
  • The student who needs a challenge could try to create a race with three sprites or a race where each sprite's code is different, but the sprites finish the race at the same time.