c1L10 - Everybody Can Code
Everybody Can Code
The goal of this lesson is to show participants that programming is not a mystery and everybody can learn it. With easy analog exercises the basic concepts of programming are introduced, which can later be transferred to an easy online programming interface. Welcome everybody to the world of code.
Preparation
Exercise "Egg carton Maze"
This exercise shows with a very simple example how computer programs work and is also suitable for kindergarten kids. You can either give participants all the material needed or ask them to gather materials at home and bring them to the class.
The target of the exercise is to move the toy figure through the egg carton maze in order to catch all the targets. Form groups of 2-3 people. One person is the computer who runs the code and the others are programmers who "write" the code.
Rules:
- The toy figure can't be placed on fields with obstacles.
- The toy figure can't be moved outside the maze.
- Only the computer is allowed to touch and move the elements in the maze.
Move commands: To move the toy figure programmers have 3 commands. Draw them as arrows on little snippets of paper:
- Move one step into the direction the toy figure looks
- Turn left (without moving forward)
- Turn right (without moving forward)
Running the exercise:
- The "computer" sets up the maze:
- Puts the toy figure to the start position (e.g. the lower left space of the egg carton).
- Places targets on the egg carton.
- Places obstacles on the egg carton.
- The "programmers" start setting up their code by putting together their list of "commands".
- Programmers are not allowed to touch and move the toy figure. If they want to do a test run, they need to ask the computer to run the code and see if their commands are right. You might notice that it can be difficult to go through the code in your mind, especially when there are a lot of rotations. This simulates the challenges of real coding. That's why programmers often do test runs with parts of their code to see if this part works or to find errors. Programmers call this process "debugging", as errors in code are referred to as "bugs".
Code example: In order to move the toy figure to the (yellow) target, programmers need to perform a minimum of 6 commands: forward, move left, forward, forward, move left, forward.
Variations of the exercise: By limiting the number of command snippets you force participants to optimize their code. This can also mean that they might not reach all targets. This simulates real conditions of coding where time and resources are often scarce.
With this exercise participants learn the basic principles of coding:
- A program or code is a set of commands a computer executes one after the other.
- If a programmer makes a mistake the code does not work. The computer is not able to fix it on his own.
- Programmers optimize their code for a minimum set of commands. This speeds up the code execution and reduces the potential of errors.
Participants might notice that the code will become very long if you have to put one snippet for each step. That brings them to the next level of coding: bundling commands. Instead of putting 4 forward commands in a row you can also use the command "execute [x] times" to make the code easier. To introduce these commands there is very good instruction and templates at: https://researchparent.com/coding-a-lego-maze/. If participants already have some knowledge about coding you can also do this exercise instead of the egg carton version:
Exercise: Scratch Programming
In this exercise participants will create a first easy program in an online programming tool called "Scratch". Two participants use one PC together, as people usually feel more confident trying out new things when they don't do it on their own.
Start the PCs and open a web browser and open the page https://scratch.mit.edu In the main menu select "Create" to start the Scratch tool:
Learn the elements of the tool with a first easy program:
- The code tab on the left side shows a list of categories. If you click on a category all available elements of this category are listed in the second column as colored elements.
- In the middle of the screen there is a central area where you can drag the elements with your mouse.
- In the upper right corner you see the output window with the cat. This is where your program is running.
Let's start setting up an easy program:
- On the code tab on the left side click on "Events".
- Select the first element "when [green Flag] clicked" with your mouse...
- and drag it to the central area of the screen.
- On the code tab on the left side click on "Motion", select the element "move 10 steps" with your mouse and place it below the yellow element. You see how the blue element snaps to the yellow one when you move it next to it. Increase the number of steps to 20.
- Click on the green flag above the output window. This starts your program and the cat moves 20 steps to the right.
Let's get to something a bit more complex. We'll let the cat ask for your name and welcome you. Try to build the program as shown in the following image. To easily find the elements they have the same color as the category. E.g. you will find the purple element "say Hello! for 2 seconds" in the purple category "Looks".
If you struggle getting the "answer" element into the last line of the code, go back to the "Sensing" section where you found the "ask What's your name" and wait" element. Right below this element is the "answer" element that you can drag to the purple element. This is an example where a program stores information in a placeholder, a so-called "variable".
That's most of the magic behind programming. In order to write more sophisticated programs you need to learn all the elements and commands of a programming language but you can call yourself now a programmer. In case participants found their passion for programming there is a lot of very good tutorials for scratch: https://scratch.mit.edu/ideas. The good thing about scratch is that it works in basically any browser without installing anything or registering.
Method / Process description
- Input: Introduce the concept of coding (Module 6 > 6.1. Introducing Children to Digital Skills > Basics of Digital Technologies) and make them familiar with the basic terms:
- Software: https://wiki.kidzsearch.com/wiki/Software
- Computer program: https://wiki.kidzsearch.com/wiki/Computer_program
- Coding/Programming: https://wiki.kidzsearch.com/wiki/Computer_programming
- Commands/instructions: https://wiki.kidzsearch.com/wiki/Instruction_(computer_science)
- Exercise "Egg carton Maze"
- Input: You can now introduce the term "algorithm" as it is nothing else then a set of rules that is executed by a computer, so it's just what participants did in the exercise. You can also compare it with following the instructions of a recipe or giving somebody directions to get to a location. Those who want to learn more about algorithms and artificial intelligence find a good online training at: https://course.elementsofai.com
- Exercise "Scratch Programming"
- Group discussion: Ask participants how they feel about their first experiences with coding. Did they have fun? Was it too complicated? Can they imagine doing this together with their kids?
- Reflection: Let participants try out the "Animate Name" Tutorial at home: https://scratch.mit.edu/projects/editor/?tutorial=name
References
- Scratch website: https://scratch.mit.edu
Short facts
Target group | Adults or children |
---|---|
Setting | Group work and plenum |
Time | 2 units à 45 min. |
Material |
|