1, 2, 3, code ! - Cycle 2 activities - Lesson 2b.6. Different types of loops


Students tell the next episode of the hero's adventure: the octopus goes to the bottom of the sea to get the treasure and bring it back to the surface. They reinforce the key ideas from the previous lessons, namely predefined loops, and learn about infinite loops.

Key ideas
 (see Conceptual scenario, page XX)


  • Certain loops are repeated forever.
  • Certain loops are repeated until a condition is met.


For the class

  • (Recommended) A computer on which the Scratch software has been installed and a video projection system.

For each student pair

  • A computer on which the Scratch application has been installed.

For each student

  • Handout 32, page XX


Infinite loop


1 hour, plus 30 minutes to connect episodes 2 and 3.


Starting the activity

The teacher reminds the students that the hero, who cannot reach the treasure he can see at the bottom of the sea on his own, must guide a submarine, represented here by an octopus. The octopus brings the treasure to the surface. Today, the students are going to program this episode of the hero's story.


Activity (ideally in pairs)

The teacher gives students their programming assignment: in the same program as the last time, they must add a new scene that appears once the octopus is visible in the sea. In this scene, they must add a "decorative" animal of their choice. It will not participate directly in the story and its movements will repeat through the scene. The teacher shows them the expected result (file "II-2b_sea_ correction_lesson6.b2), which uses new "Control" instructions:



The teacher tells the class about these instructions: they are loops, but you cannot decide ahead of time how many times they will be executed. Some of these loops have a hexagonal field that must be filled in with an instruction in the same shape. Some can be found in the "Sensing" instruction category (as well as in the "Operators" category, but these will not be useful here), such as:



Combinations such as above can be found, and the teacher can describe them to the class and test them on the cat sprite:



The cat sprite moves 10 steps, stops for one second, then starts again until it touches the edge. If it is touching the edge from the start, it does nothing. If it starts near the edge, it will take one or two steps; if it starts far from the edge, it will take more steps.

Once students have understood, the teacher suggests inactivating the scripts for the first two episodes of the story (to do this, simply disconnect them from the trigger event) to they can focus on the current episode. They must try to get a similar result as the one the teacher showed them, but it does not have to be exactly the same.


Group discussion

During the group discussion, the teacher goes over any difficulties students had. The teacher guides the discussion to new loop types: the "repeat forever" loop and the "repeat until ..." loop. If there is enough time, students can revise their programs following the group discussion. If not, the students can make any corrections during the extra 30 minutes dedicated to this lesson to connect episodes 2 and 3.

The file "II-2b_sea_correction_lesson6.sb2" provides an example of the result once the scripts for the first two episodes are reactivated and after the dock and sea episodes are linked.

Teaching note:
Some students will use instructions the class has not yet seen. At this point, when they begin to have a good understanding of the software, it is important to let them express their creativity. But to help them continue learning, the teacher should encourage them to regularly test their programs. It is much more difficult to detect a bug in a program written as a block without tests than in a program that has been tested throughout the writing process.


Conclusion and lesson recap activity

The class summarizes together what they learned in this lesson:

  • Certain loops are repeated forever.
  • Certain loops are repeated until a condition is met (for example, a sprite touches another sprite, or a sprite touches a certain color).

The students write down this conclusion in their science notebook and complete the Scratch worksheet by coloring in the new instructions they learned and writing down a few key words: infinite loop, condition, touch a sprite, touch a color.



<< Séance II-2b.5 Séquence II-2b Séance II-2b.7 >>


Project partners

Aucun résultats