1, 2, 3, code ! - Cycle 1 activities - Lesson 1.4. Conditional routes: Treasure hunt

 

Summary

Students enrich their programming language with conditional constructs (if–then statements).

Key ideas

(see Conceptual scenario)

"Algorithms"

  • A program is a combination of instructions.
  • In a program, tests say which instruction should be done when a condition is met.

Inquiry-based methods

Experimentation

Equipment

For the class:

  • An avatar
  • A poster on A3 or A2 size paper with a 3x4 grid
  • Several copies of the instruction cards from Handout 1
  • Treasure chest cards from Handout 4 and Handout 5
  • New instruction cards: Handout 6 and two copies of Handout 7

Glossary

Conditions, tests

Duration

45 min, can be split into two sessions

 

Preparation

To fill in the grid used during the previous lessons, the teacher creates or has students create tokens with treasure chests on them. The treasure chests can be green, red or neutral (gray). On the back of the red chests, draw a monster. On the back of the green chests, draw a reward.

The corresponding cards are found on Handout 4 (cut on the solid lines and fold on the dotted lines). After folding, the coins are hidden behind the green chests and the skulls are on the back of the red chests.

 

Starting the activity

The teacher takes the grid from the first lesson and adds green and red treasure chests along the routes (Handout 4). For example on the right:

The teacher presents the treasure chest cards and explains the game rules: If an avatar opens a green chest, it gets a reward. If it opens a red chest, the monster inside will scare it and it will have to go back to the starting point. The teacher asks the class a simple question: "Using the programming language we already used, will the avatar know how to open the treasure chests?" No – it only knows how to move around. The teacher then introduces a fifth programming language glossary term: "Open the chest" (the corresponding card is found on Handout 6).

 

   
   
   

 

To emphasize that this card is essential to opening the chest (without this instruction card, the chest cannot be opened), the teacher suggests doing this first route as a class to help the avatar safely gather all the rewards and make it to the final destination. The teacher even gives students a program (which deliberately contains an error):

 

   

 

Open the first green chest, then build suspense by moving by the first red chest without opening it, but then forget to open the second green chest, and instead open the second red chest. This demonstration will help students remember that simply being on the same square as a chest does not mean it can be opened.

As a class, the students suggest how to correct the error:

 

   

 

Experiment: Collect all the rewards while avoiding the monsters (as a class)


 

 Following this practice exercise, the teacher traces out a new route, such as this one:

 

Preschool and kindergarten classes, Laurence Bensaid, Paris

 

The teacher then asks the class to write a new program that will let the avatar safely collect all the rewards and return home.

   
 
 
   

The class finishes this example with a program like this one:

 

 

Experiment: Gathering all the coins along an unmarked route

This time, the teacher shows the class a similar route, but with one difference: the treasure chests are not red or green, but rather gray. Under each treasure chest card with a gray chest is hidden a colored treasure chest card (green or red), which indicates whether the chest contains coins or a monster. "The avatar already knows where the treasure chests are, but does not know what color they are. What does it do?"

The class discusses the fact that the avatar must go to all the squares with a chest, but it needs to check whether the chest is red or green before opening it.

The class begins by trying to verbalize the necessary instruction.

IF the chest is green THEN it must be opened.

 

 

 

Scientific notes:

  • The teacher can explain that if the condition is not met, nothing needs to be done: IF the chest is green, THEN it must be opened, OTHERWISE it isn't opened.
  • When the avatar is on the same square as a red chest, it still obeys this instruction and does not open the chest. This is neither an error nor disobedience.
   
 
 
   

The teacher then suggests a new instruction card (found on Handout 7). This card is a test; it includes a condition (here, "Is the chest green?") and the instruction (here, "Open the chest") to follow if the condition is met.

During the exercise, when the avatar asks the question, the teacher removes the gray treasure chest card and reveals the chest's real color.

The class should improve the previous program with this new instruction to help the avatar safely collect all the coins and arrive at the destination.

 

The final program created by the class may be similar to this one:

 

The instruction appears four times, once for each chest, because it is impossible to know ahead of time where the green chests are.

 

Conclusion

The class summarizes together what they learned in this lesson:

  • In a program, tests say which instruction should be done when a condition is met.

 

Further study

Suggest other routes, asking how many rewards the avatar will collect using the program.

  • For kindergarten classes: You can ask the students to create an "OTHERWISE" card: for example, "IF the chest in green, THEN the avatar opens it to get the reward, OTHERWISE it buries the chest so its friends won't accidentally open it."

 

 


<< Lesson 1.3 Sequence I Lesson 1.5 >>

 

Project partners

Aucun résultats