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, modifies and creates codes 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 includes plugged-in coding activities, that is, coding that requires software, a platform or a coding device. It is possible, however, to adapt the activities so that they are unplugged.

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 creating and modifying 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 creation and modification of a 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.

Prerequisites

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

Success Criteria based on the Achievement Chart Categories

Skills Success Criteria
Knowledge and Understanding
  • The student knows the appearance and function of blocks in the coding software 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 Skills
  • The student plans the location and duration of a "pause" block to properly synchronize concurrent events in their code.
  • The student predicts the outcome of a code and modifies it 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 modifies a code and determines the effect of the changes on the behavior of a sprite.
Communication
  • The student explains his/her 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).
Implementation
  • 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 a code sequence allowing more than one sprite to move at the same time;
  • read a code sequence, then modify it to make it more efficient.

Materials

  • block programming software 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).

Scenario

Duration: 10 minutes

Assessment can be carried out through…

Computer évaluation: Conversation, observations, productions.

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.

Children playing in the garden with obstacle games.

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 gets there first is the winner.

Action

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

Assessment can be carried out through…

Computer evaluation: Conversation, observations, productions.

Introduce students to a code, such as the one below, by displaying it on a screen or using colour photocopies.

Sprite butterfly. Block start on green flag, move right one time two times, move up one time, move right one time two times, move down one time, move right one time two times, end.

Ask students to find a partner. Have them work through the code together to describe the movement of the butterfly. When students are satisfied with their answers, have them do the same exercise using the bird code below. This time, since the teams may be moving at different rates, it would be best to give them colour photocopies made on strips of paper.

Sprite bird. Block start on green flag, move right one times, move up one time, move right one times, move up one time, move right one time, move up one time, move right one time, move up one time, end.

Back in the classroom, facilitate a conversation to compare the two codes.

Questions to ask and possible responses from students:

  • Who travels farther, the butterfly or the bird?
    • The butterfly travels farthest, as it moves 6 squares to the right, while the bird moves only 4 squares to the right.
    • The bird travels the farthest, as it moves 4 squares up, while the butterfly moves one square up, then one square down.
  • Who will have completed their move first?
    • Both animals have 8 blocks in their code, so both will complete at the same time.
    • The bird only has 4 move blocks to the right, so it will end its move before the butterfly.
  • What does the green flag mean in the code?
    • This is the starting signal.

Allow students access to their chosen block coding software to recreate the code and check their answers to the questions.

Afterwards, allow the students some time to experiment with the software in order to modify the given code to change the behaviour of the butterfly and that of the bird. This gives students the opportunity to experience the effect of changing, adding and omitting certain blocks of code.

Possible Observations Possible Interventions
The student code does not look like the seed code shown at all. Ask the student to explain aloud the blocks of their code and their effect.

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.

Now give students a more specific purpose for their 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.

Scene of a classroom created with coding imagery. The scene has two butterflies, two chairs, two tables, a green carpet, a glass, and a terrestrial globe.

Possible yellow butterfly code:

Coding line:Sprite butterfly. Start on green flag, move up two times, move right 4 times, 4 down 3 times, move right 6 times, move up two times, move down two times, move right 3 times, move up 3 times, move right one time, move up one time, move right two times, move down two times, move right two times, move up 3 times, move left one time, move down two times, move right one time, say ‘I’, end.

Possible purple butterfly code:

Line of coding: Sprite butterfly, move up time two times, move right 4 times, move down 3 times, move right 11 times, move down one time, move right two times, move up one time, move right two times, move down 3 times, move left 3 times, move up two times, move right one time, say ‘I’, end.

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 modify the blocks, one at a time, and perform the code with each 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 software programs allow students to record their voice, which offers them the opportunity to create a narrative for the race and, also, to communicate their understanding of the concepts orally rather than in writing.

Bloc of sound recorded by user.

Example of a block allowing voice recording in ScratchJr.

Consolidation

Duration: 15 minutes

Assessment can be carried out through…

Computer evaluation55: Conversation, observations, productions.

  • Choose a few codes to present to the class. The choice can be made by asking for volunteers or by strategically selecting codes that emphasize the learning goals of familiarizing students with the relative movements and positions of objects and simultaneous events.
  • Ask the selected teams to present their code to the class. The team must explain their code and the rules of their obstacle course (what moves to make and how to win). Then, the class analyzes the code to try to predict who will win the race. Finally, the code is run to see which sprite will win.
  • Ask students the following questions:
    • How do we make sure that both codes 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)

Bloc start the script when tap on the character.

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 an 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 software could be useful for students who do not yet have a good knowledge of the software.
  • 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.