Copyright © by Mark Baker 1997
Return to MarkChrisSoft home page
This Logo worksheet is based on a public domain (i.e. freely available) implementation of Logo, that runs on an MS-Windows platform. It can be found by visiting CNet's shareware library and searching for MswLogo. The general structure however, is applicable to any version of Logo.
This allows instructions to be entered and executed immediately. Type your instructions into the input box, then press return. There is a triangular pointer on the main MswLogo screen, this is called the turtle (for historical reasons)! The turtle obeys the commands or instructions, that you type into the Commander. This is an artistic turtle and it is holding a pen, so that when it moves, a line is drawn on the screen.
To repeat an instruction entered earlier, click on it in the window above the input box (the output box), then press return. Alternatively, you can double click on the item.
Press the Status button to see what Logo is doing at any time. Press the No Status button to close the status window.
|forward, back||Moves the pen forwards/backwards, eg. forward 100 moves the pen forward 100 units|
|right, left||Turn right/left e.g. right 90 means turn right 90 degrees|
|pen up||Picks up the pen so that it is above the screen|
|pen down||Puts the pen down on the screen|
|arc||Draws an arc. arc 360 50 draws a full circle, of radius 50. arc 180 50 draws a semi-circle of radius 50.|
|home||Returns the turtle to its starting position|
|clearscreen||Clears the screen (rubs everything out) and returns the turtle to its starting (home) position|
Note: Spaces are important.
forward100 is illegal, forward 100 is legal
right90 is illegal, right 90 is legal
1. Click on the input box and type in these instructions. Draw a sketch in your books to show the shape that is drawn:
2. What do these instructions draw? Draw a sketch of it in your books.
3. What do these instructions draw? Draw a sketch of it in your books.
arc 360 50
arc 360 50
These programs take a lot of typing, so Logo allows you to use abbreviations for some of the most common commands.
|forward, back||fd / bk|
|right, left||rt / lt|
4. What do these instructions draw?
For each of the questions below, draw the shape on the screen first, then write the instructions into your book.
5. Write down the instructions that will draw a square, with sides of
6. Write down the instructions that will draw a triangle, with sides of length 100 (see diagram below).
7. Write down the instruction that will draw a circle, of radius 50.
8. Write down the instructions that will draw these shapes. Enter them on the computer and debug (correct) them. Write the correct instructions in your book.
Often you want to repeat the same instructions several times, e.g. when drawing a square you would need:
fd 50, rt 90, fd 50, rt 90, fd 50, rt 90, fd 50, rt 90
To make this easier you can use a loop structure (or repetition structure) to repeat the same instructions as many times as you like. You could draw the square using these instructions:
repeat 4 [fd 50 rt 90]
Everything inside the bracket is done four times.
9. Try to draw a square using the repeat instruction. Write the instructions
that you used in your book.
10. What shape do these instructions draw?
repeat 8 [fd 40 rt 45]
11. Draw a hexagon (six-sided shape) using the repeat instruction. Write
the instructions that you used in your book.
12. Draw a rectangle using the repeat instruction. Write the instructions that you used in your book.
Using Logo to draw a complicated picture would take a long time. Often you would be repeating the same basic shapes, squares, rectangles and so on. Logo allows you to write procedures which are useful sets of instructions. You can then call them up whenever you want to.
13. Type in these instructions, which will create the procedure DrawSquare:
repeat 4 [fd 100 rt 90]
Now enter the instruction "DrawSquare" (this is known as "calling the procedure") and explain what happens.
14. Write a procedure in your book that will draw a rectangle. Enter
it on the computer to test that it works.
15. Write another procedure, to draw a shape of your own choice. Write the instructions into your book and draw a sketch to show what happens when you call your procedure.
The DrawSquare procedure is very useful, so long as you always want to draw a square where all the sides are 100 units long. It is no good if you want to draw squares of different sizes. It would be much more useful if you could vary (change) the size of the square.
A parameter is a value that you send into a procedure and you can use a parameter to change the size of the square that is drawn. For the square procedure we want one parameter, the length of the sides.
to DrawSquare2 :length
repeat 4 [fd :length rt 90]
16. Enter this procedure.
17. Enter these commands:
18. Sketch the design that these three commands draw.
19. Enter this procedure.
to Draw :length
repeat 3 [FD :length RT 120]
20. What shape does it draw?
21. Use this procedure to draw four shapes, all of them a different size.
22. Enter this procedure:
to polygon :length :sides
repeat :sides [FD :length RT 360.0/:sides]
23. Use this procedure to draw some shapes, using different numbers
for length and sides.
24. Explain what the procedure POLYGON does.
You should always try and put helpful comments in your programs, so that other people can understand what you have done. You can do this in Logo by typing a semi-colon. Anything that comes after the semi-colon is ignored by the program and is just there as a programmer's comment.
eg. FD 100 ;this moves you forward 100 units
|setpensize[10 10]||Sets the width of the line drawn to 10 units|
|setpensize[1,1]||Sets the width back to normal again|
|setpencolor[255 0 0]||Sets the colour of the pen to red. Other colours
[0 255 0] green
[0 0 255] blue
[128 128 128] grey
[0 0 0] black
|setpencolor [r g b]||The general case, where r = amount of red,
g = amount of green and
b = amount of blue, all numbers from 0-255.
25. Create your own picture or design, using Logo, using different pen
colours and different line widths. You should try and use some of the procedures
that you have already entered. You might want to write some new procedures
26. Draw a sketch of your picture/design in your book and write down the commands that you think you will need.
27. Enter the commands on the computer and correct any errors (bugs) in your program.
28. Add some comments to your program, to explain what you have done.
29. Print out the finished program and glue it into your book.
30. Explain what bugs you found in your program and what you had to do to correct them.
Here are some additional commands that you might like to experiment with.
setpos[x,y] (must use penup if you do not want a line drawn from your current position)