9. The turtle is learning

If you managed to pass the lessons successfully so far, you might have seen that it is not that easy to edit the commands you give. To simplify to process you can teach Logo's Turtle a series of commands, a series of instructions. Teaching the turtle is simple. Write the command

Teach the turtle what is a dashline using the command line shown above

**to**followed by the word you want to teach the turtle and at the end write the line of commands for the turtle to learn. For example :**to dashline repeat 5 [setwidth 1 fd 10 setwidth 3 fd 10] end**. This command will teach the turtle a new word: dashline. (dashline = create a dashed line).Teach the turtle what is a dashline using the command line shown above

Now you will see that the turtle really does remember what he learned. To ask the turtle to draw a dashed line just repeat the new instruction word you taught him before.

Draw a dashed line using the new instruction (the new word) you taught the turtle before

Draw a dashed line using the new instruction (the new word) you taught the turtle before

You have drawn a dashed square before, but now it will be much easier. Use the word we taught the turtle before to draw a square.

Draw a dashed line square by drawing 4 dashed lines and using the turning right command.

Draw a dashed line square by drawing 4 dashed lines and using the turning right command.

You might want to draw the same square again, therefore you can teach the turtle what is your favorite square.

Ask the turtle to learn how to draw a square like the one you drew before

Ask the turtle to learn how to draw a square like the one you drew before

Now you can easily draw a dashed square using only one word.

Clear the screen and draw again the same dashed square as before.

Clear the screen and draw again the same dashed square as before.

This next strange symmetric figure we are going to draw will consist of 20 dashed squares. Between one square to another we will turn right at an angle of 360/20 = 18 degrees. Remember that the turtle already knows how to draw a dashed square. So all we have left to do is define the loop which will create the squares correctly.

Clear the screen and draw twenty dashed squares

Clear the screen and draw twenty dashed squares

You have already taught the turtle which is your favorite dashed line, but what if you'd like to draw a different dashed line? In that case you can teach the turtle the same word again, only this time it will be with different instructions. The turtle will only remember the very last commands he learned.

Teach the turtle again what is a dashline. Use an instruction similar to the one we had at the beginning of the lesson, but now make the wider segments to be 6 points wide instead of 3.

Teach the turtle again what is a dashline. Use an instruction similar to the one we had at the beginning of the lesson, but now make the wider segments to be 6 points wide instead of 3.

Why should be check how the new dashed line looks like when we can already check how a whole square made out of dash lines looks like? Ask the turtle to draw a square. Notice how he is different from the square the Logo turtle drew before, with the same simple instruction.

Draw a square using the instruction we already taught the turtle

Draw a square using the instruction we already taught the turtle