1, 2, 3, code ! - Cycle 2 activities - Lesson 2a.5. Predefined loops and infinite loops


Students tell a new episode of their hero's adventure. They reinforce the key ideas from the previous lessons, namely predefined loops, and learn about infinite loops.

Key ideas
(see Conceptual scenario)


  • Certain loops are repeated forever.


For the class

  • (Recommended) A video projector system to show the teacher’s tablet screen to the entire class.

For each pair or small group

  • An Android or OS tablet with the Scratch Junior application installed

For each student


Infinite loop


1 hour


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 a seahorse. The seahorse 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 stage that appears once the seahorse 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. For a script to repeat forever, they must place the following red instruction at the end of the script:


The students must then make the seahorse appear and go to get the treasure by making back and forth movements to the left and right, descending gradually. The treasure is in a chest at the bottom of the sea. When the seahorse touches it, both go back up to the surface at the same time. To trigger a script when two characters touch, the following yellow instruction must be used:


As during the previous lesson, the teacher lets students play around with the software, offering as little help as possible so problems emerge. If necessary, you can show several commands to the class using the demonstration tablet, but students should be increasingly independent. However, you should remind them to save their programs with the names AH3 or BH3 (depending on their group).

Teaching note:

You can pre-program each tablet with part of the lesson and have students complete or modify the program.


Group discussion

During the group discussion, the teacher goes over any difficulties students had.

For example, if the seahorse's ascent is triggered when it touches another character, the "decorative" animal mustn't touch the seahorse while it descends. The students must choose the seahorse's positions and movements so as to avoid the two coming into contact.

Here are a few programs for each character (seahorse, treasure chest and decorative fish) that follow the directions, but students will come up with a variety of solutions.

The initial positions that are compatible with these programs are:

  • Seahorse: (row 14, column 4)
  • Treasure chest: (row 2, column 3)
  • Decorative fish: (row 12, column 18)

An intermediate view of the scene looks like this:

Teaching note:
Some students will use instructions the class has not yet seen (especially as the Scratch Junior worksheet provides a preview of all commands). 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:

  • A loop is used to repeat the same instruction several times.
  • Certain loops are repeated forever.

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



<< Lesson 2a.4 Sequence II-a Lesson 2a.6 >>


Project partners

Aucun résultats