1, 2, 3, code ! - Cycle 2 activities - Lesson 2a.3. Simplifying a program by using loops

Summary

The students continue learning to use Scratch Junior by exploring the instruction "repeat...," which is a loop. They practice anticipating what a program given to them will do, combining loops and movement instructions. Finally, they revise their initial program by replacing the repeated instructions with loops.

Key ideas

(see Conceptual scenario)

“Algorithms”

  • A loop is used to repeat the same action several times.
  • Certain loops are repeated a specific number of times.

Equipment

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

Glossary

"Repeat..." loop

Duration

1 hour

 

Starting the activity

The teacher tells the class they are going to take a break from the story to learn a new type of instruction that they can use in their stories later.

They put the saved program from the end of the previous lesson on the board (either with the projector or written):

This program has only 11 basic instructions, but it takes up a lot of space in the programming area. If they want to keep telling the story, the program may become very long and complicated. The teacher tells them that today they are going to learn to identify instructions that are repeated to simplify them. To do this, they will use an orange instruction which is available after tapping on the icon  :


 
This instruction is like a bridge above one or more instructions. The students will have to experiment to understand what it means. They will then be ready to simplify the script that controls their hero's movements.

 

Activity (ideally in pairs)

The teacher gives the students two assignments (one after the other):

  • They must first use the "orange bridge" instruction to make the cat move in a stair step direction (one step right, one step up, one step right, one step up, etc.). The cat must start in square (row 3, column 3) and "climb 7 steps" when you tap on the green flag.
  • Once the first assignment is completed, the must then use the "orange bridge" instruction to have the cat move all around the stage three times in a row (starting from square (row 3, column 3)).

Teaching notes:

  • You can have students place the two previous scripts in the same programming area and have them triggered by different events: "tap on the flag" and "tap on the cat."
  • An alternative option is to create a new character and assign one script to the cat and the other to the new character, both triggered by whichever events the students want.

 

Group discussion

For the first challenge, a correct program that follows all directions is:

The teacher asks the students if they figured out what the orange instruction that looks like bridge does. The class concludes that this instruction requires the instruction block it encompasses to be repeated the number of times indicated on the instruction. The class gives this instruction a name, such as "Repeat..." If the students do not talk about loops on their own, the teacher reminds them about this term by referring to the previous sequence (Lessons 1.5, and 1.6). The teacher explains that they can include a loop each time the instructions are repeated.

For the second challenge, a correct program that follows all directions is:

The students save their second practice program as "AP2" (for class group A) and "BP2" (for class group B).

 

Exercise (individually within small groups)

The teacher puts up a simple program on the board using loops and movement instructions:

They ask the students what the character will do if they start the program. The students must trace the character's movements on a grid (Handout 22).

During the group discussion, the students compare their answers (especially the destination row and column), and check them as a class by launching the program. The path followed by the cat is the following:

 

 

Simplifying the program controlling the hero's movements (ideally in pairs)

To finish the lesson, the students apply what they learned to simplify their program from Lesson 2a.1, which controls the hero's movements. The original program (given above) becomes:

The teacher reminds the students to save their modified program, without changing the file name (e.g., AH1 for group A).

 

Conclusion and lesson recap activity

The class summarizes together what they learned in this lesson.

For younger students:

  • A loop is used to repeat the same instruction several times.

For older students:

  • A loop is used to repeat the same instruction several times.
  • Certain loops are repeated a specific number of times.

The students write down these conclusions in their science notebooks.

The students then complete their Scratch Junior worksheet: they color in the instruction they learned in this lesson in orange and add a few words: "Repeat..." loop, number of repetitions.

 

Further study

The online exercise below is a complement to review the concept of loops.

permet de se réapproprier le concept de boucles :

 


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

 

Project partners

Aucun résultats