# Algorithms

__Learning Objectives: __

**1) To understand what algorithms are and why we need them.**

**2) To know how to use algorithms to draw geometric shapes in Scratch.**

Starter: The robot game or SketchBot! (5 mins).

**What is an algorithm? **It is a *sequence of instructions* to be carried out until an *end point* is reached. Think of a food recipe. When you're writing any sort of program, the most important thing is the *algorithm* - the plan, or design, for what your program is going to do. The algorithm should be written in a language-independent form - *flowcharts* and *pseudocode* are common forms used for representing an algorithm. Use Prezi resource.

Discuss whether it would be good if people followed instructions exactly. E.g. what would happen if you pointed to a closed door and said “Go through that door?” Explain that computers work by following lists of instructions, and that they do exactly what the instructions say, even if they are incorrect (or nonsensical).

This lesson explores algorithms for drawing images. This lesson shows the importance of writing and interpreting algorithms correctly. (10 mins)

Development:

Show Big Bang Theory. (2 mins).

http://www.advanced-ict.info/theory/NC/index.html

Create own algorithm for a mystery place in the school using a flow chart handout. Test it on a partner. Refine it if necessary. Use loops if steps should be repeated. (10 mins).

Once the previous activity is finished, project the Draw a Square Program from Scratch (see link below) and ask them to figure out what it does. Ask the students to create the script themselves in Scratch to see what it does. Explain the commands hide, clear, pen up, pen down, set pen colour to, and pick random number as described in the diagram. Create own algorithm for a program to draw a circle and triangle in Scratch. Work with partner - try to get the partner to act out the instructions to see if it works. Create the code in Scratch. (15 mins)

*Extension: Ask students to draw something interesting using 4 or 5 shapes. They can use different pen sizes and different colours e.g. a house, a car or a smiley face.*

Plenary: Students test each other's programs and recommend a partner to show off their work. If time, ask students to think of 3 things they have learnt this lesson. Share. (5 mins)