Repeat commands
Programming with Logo - Lesson 4
Objectives
- To use repeat commands in Logo to draw regular shapes
- Use logical reasoning to predict what a simple program will do
Lesson Resources
Lesson 1 - Introducing Logo
Lesson 2 - Drawing Words
Lesson 3 - Adding Colour
Lesson 4 - Repeat Commands
Lesson 5 - Procedures
Lesson 6 - Progressing To Scratch
Introduction
Remind the children of the first lesson on Logo where they drew shapes, how many commands are needed for drawing a square? Ask them to discuss this with a partner and come up with a number.
Establish that it needs 8 instructions for the robot to draw the shape and return to its starting positions: 4 that draw the sides and four that turn the corners.
What if there was a way to speed this up!? Introduce repeating and share today’s objectives.
Repeating
A repeat command tells the robot what to do and how many times to do it. It must be written in a special way so the computer understands what to do.
rpt 4 [fd 5 rt 90]
Here’s what it all means:
rpt = repeat
4 = how many time to repeat
[ ] = square brackets are used to tell the computer what to repeat
fd 5 rt 90 = the instruction to be repeated
What do you think this instruction will draw? Ask them to type it in and try it out. Did it work? Correct any errors (usually forgetting spaces or brackets) What did it draw? Establish that this repeat command also draws a square so 8 instructions have just been shortened to 1!
Main task
Show the children the ‘Repeat commands’ sheet and ask them to make a prediction for what it will draw for each command, then they must test the commands and add to their sheet what it actually drew (with words or pictures).
Below are some further examples of repeating commands to draw shapes:
rpt 4 [fd 2 rt 90]
rpt 5 [ fd 2 rt 72 ]
rpt 6 [ fd 2 rt 60 ]
rpt 8 [ fd 2 rt 45 ]
rpt 9 [ fd 2 rt 40 ]
rpt 10 [ fd 2 rt 36 ]
rpt 12 [ fd 2 rt 30 ]
rpt 15 [ fd 2 rt 24 ]
Plenary
Review their work, how good were your predictions? how did you make your predictions? Was there anything in the code that helped you?
Establish that the repeat number is the number of sides that the shape has.
Why was the last one tricky? The last one draws a circle and is done by drawing 60 very short straight lines to make the curve. In this case the repeat number does not match the true number of sides of a circle.
What do you think is special about the rt number each time? Will any number work here as long as we have the correct number of repeats (sides)? The rt number is the angle of the corners of the shapes. If you multiply the rpt number by the rt number it should always equal 360, why is this?