Lesson 8: Creating a Function

Operational Goals

The student:

  • determines directions and establishes the position of the robot in relation to oneself, as well as in relation to other objects, distinguishes the left and right side, up, down,
  • arranges a sequence of instructions for the robot using directional arrow blocks,
  • reads the sequence of instructions written using directional arrow blocks,
  • avoids obstacles in the form of maze walls,
  • can extract the largest repeatable sequence from a long sequence (new goal),
  • can change a piece of code into a function (new goal),
  • arranges a sequence of instructions with a function call (new goal).

Brief Description

Using simple exercises in the Go Lumi! app, students will create sequential algorithms using functions to move the robot on an interactive board and guide it through the maze from the Start field to the Finish field. To do this, students will set the appropriate blocks with instructions on the interactive board into strings - thus creating a function definition and an algorithm - a sequence of instructions - for the robot.

Exercise Goals

During this lesson, students will develop skills in defining functions and programming using functions, as well as debugging skills. The exercises will help students understand why changing pieces of code into functions can be a helpful practice. They will learn to extract the largest repeatable sequence from a long sequence. The block-based form of instruction helps students get to know and understand the sequence, function, and the idea of building and simplifying program code without worrying about perfecting syntax.

Lesson Plan

Duration: 45 min


Duration: 15 min

Game: Sing a Song

Group exercise:

Start with a simple song, written or displayed on the screen, preferably one that the students know. Agree with them that at the sign of the chorus, everyone sings the chorus together. Point out the chorus and make sure the class understands the rule before you start the song. Start singing the song. It is quite likely that most of the class will sing the words to the chorus when you show the part indicating the chorus. After the next chorus, stop the song.

Ask: What just happened?

Encourage to think: We defined the chorus. I called the chorus. You sang the chorus. Why do we have the chorus written only once at the top of the song?

Share ideas: Listen to all the answers. Ask auxiliary questions: What are other benefits of writing the chorus only once when we sing it many times?

Summarize: A song is like a computer program. Defining a name like Chorus for a small piece of the song that you use often is called creating a function. It is helpful for computer scientists for the same reasons it is helpful for songwriters. Today we will learn how this technique is used in programming.

New Concepts

repeat together: Function

A function is a piece of code, a certain sequence of instructions, which can be defined once and called (used) many times in the program.

Main Exercises

Duration: 25 min

Go Lumi! Level 71 - 80

Exercises in the Go Lumi! app dedicated to lesson no. 2: Level 71 - Level 80.

  1. Choose the simplest board appropriate for the lesson topic - Level 71 - and with the help of students demonstrate the principle of working in the application and explain the principle of building functions. Challenge students to find a layout of the road in the maze that repeats itself. Let students define the first function. And then solve the first board together.

  2. When running the program code, you can call Drive + the name of your robot!

  3. Choose a convenient way to work with the group on the interactive floor:

    • Divide students into teams or pairs that will solve individual boards.
    • All teams can work in parallel, designing a sequence of instructions for the robot on a piece of paper or using self-prepared cardboard blocks. The selected team transcribes or arranges the code on the board.
    • Check all or selected team solutions on the interactive floor together.
    • Choose a person who will mimic the robot and execute commands according to the designed sequences, moving in the maze on the board. Then run the code and compare the results. If they differ, look for where the error crept in.
    • Follow the course of the robot's movement in the maze and compare it with your code on the board or on paper. In case of incorrect behavior of the robot in the maze or a different course of driving than in the students' instruction sequences, look for the cause in the code-sequence.
  4. Match the next levels of boards to the students' skills.


Not all boards from a given lesson need to be completed during the lesson. Solving two boards during the lesson can also be sufficient. Adjust the pace of work to the needs of the students.


Duration: 5 min

Ask students to draw or write about what they learned during the lesson and what emotions accompanied them during the exercises. Ask them to write down questions if they have any.

Extended Teaching

If necessary, define homework for those interested, e.g.

  1. List examples of different devices at home. What functions do these devices perform?

  2. Create a song with a chorus. Write the chorus at the top and refer to it after each verse. If the chorus is to be repeated several times in a row after the verse, mark it in the song.

Preparation for the Lesson

  • You can search for the lyrics of some popular songs on the Internet. Show students that the standard for repeating words in songs is to define the chorus at the top and call it in the song content, after each verse.
  • Make sure students have a pencil or pen, a notebook or notepad in which they can write notes, thoughts, draw.
  • If you plan to use additional worksheets or other materials during the lesson, make sure you have enough for the students.
  • If you plan to conduct a discussion, prepare additional questions.
  • Review the exercises before the lesson to identify potential problematic areas for your students.