Let the turtle decide
Page 11The turtle always does what you tell him to. If you tell him FD 100 he will walk FD 100. But what if you want him to decide for himself how many steps to take? Then you can use RANDOM. Try this:
Try it. Then try it some more. It's not always the same.
RANDOM 10 means that the turtle chooses a number between 0 and 9. The turtle is a little crazy so he can choose any number. You never know which one. Nobody knows. We say that the turtle selects a random number.
Let's try something fun:
What happened? My turtle drew this:
But I'm sure your turtle drew something else. That's what's so fun with RANDOM. You never know what you'll get.
You can change pens with RANDOM too. Anywhere you could use a number you can also use RANDOM. Like this:
Can you think of more things to do? Maybe you can combine RANDOM with SQUARE? Or with CIRCLE? Or STAR? Or with something else? Only you know what you want to use it for.
One more thing:
Wouldn't it be fun to see the turtle while he's drawing? Sometimes you want him not to be so fast. You can tell him to slow down with WAIT and a number. The larger the number the longer he waits. Try this:
Click on the "Halt" button if he takes too long.
These are the words we know now. RANDOM and WAIT are new:
| Logo word | What it means |
|---|---|
| FD 100 | Walk forward 100 steps |
| BK 100 | Walk backward 100 steps |
| LT 90 | Turn left (good for drawing squares) |
| RT 90 | Turn right (good for drawing squares) |
| LT 120 | Turn left (good for drawing triangles) |
| RT 120 | Turn right (good for drawing triangles) |
| CS | Remove everything you have drawn |
| HOME | Move back to the starting point (and draw a line) |
| PU | Lift the pen so you won't draw when you walk |
| PD | Put the pen towards the screen again | REPEAT 10 [ ] | Repeat what's in the box 10 times |
| SETPC 4 | Change the pen to pen number 4 | TO ... END | Remember the word after TO in the future |
| ; | Don't listen to me now | PRINT [I'm a turtle!] | Say "I'm a turtle!" |
| RANDOM 10 | Choose a number from 0 to 9 | WAIT 60 | Wait for 1 second. |
These are the words we have taught the turtle. They are the same as on the last page:
| New Logo word | What it means |
|---|---|
| SQUARE | Draw a square |
| CIRCLE | Draw a circle |
| STAR | Draw a star |
Turn page, or go back to the table of contents.