0% found this document useful (0 votes)
18 views

LOGO Workbook

LOGO WORKBOOK

Uploaded by

kvartet-4f
Copyright
© Attribution (BY)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

LOGO Workbook

LOGO WORKBOOK

Uploaded by

kvartet-4f
Copyright
© Attribution (BY)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

LOGO

Workbook
LOGO
L O G O (o f t e n r e f e r r e d t o a s
Turtle / Roma) is a procedural
programming language which
allows the user to program a turtle-
like cursor around the screen which
draws a line everywhere it goes.
LOGO was first created by Daniel
G . B o b r o w, Wa l l y F e u r z e i g ,
Seymour Papert and Cynthia
Solomon as a project for a research firm called Bolt, Beranek and Newman (BBN) based in
Cambridge, Massachusetts. Although since its inception in 1967 there have been many
different implementations of LOGO, with many different syntax’s, the general
functionality has stayed the same to this day.

During this workbook which introduces you to LOGO, you will be presented with a range
of different tools and techniques which allow you to create an array of different outputs
using XLogo. Although we will be using a software version of LOGO, LOGO has also been
implemented as a physical robot which will follow the programmers commands across a
mat.

1. Download

Download the software from the following link: http://xlogo.tuxfamily.org/

A command is an instruction, which the computer can understand and execute. In


principle, the computer only understands very basic commands, which can then be
combined to form more complicated instructions. Such a sequence of commands is
combined to form more complicated instructions which is referred to as a program.

To begin, draw a straight line. You can use the command “forward 100” to instruct the
cursor to move forward 100 steps. On moving each step it will leave a line over the steps it
has taken.

1
LOGO
2. Drawing a straight line

Move 150 steps forward.

3. Combining instructions

Instruct the cursor to move 400 steps forward and then 100 steps backward.

There is another way to command the cursor to move forward and backward. You can use a
shorthand notation for forward, “fd" to instruct the cursor to move forward. Have a go at
working out what the shorthand notation for back is.

Hint: It is in the Command Cheat Sheet at the back of this workbook. You can also
clear any lines drawn by the cursor and reset the cursor to its initial position by using
the command “cs".

When we command the cursor to move forward it will always move in the direction that it
is facing. We can turn the cursor to the right by using the command right 90 which will
instruct the cursor to move 90 o to the right. This relates to turning the cursor by a quarter
circle. You can instruct the cursor to move any number of degrees including negative
numbers.

2
LOGO
A program is when you chain together a collection of commands. We can create a program
in XLogo by making a sequence of commands.

4. Creating a program

Create a program which creates square where its sides are 100 steps long. You can do
this with a minimum of 8 commands. (Including returning the cursor to its original
position).

5. Program
50
50
Create a program which creates the following image:
50

Within XLogo you can repeat instructions so that you do not need to type them in more
than once. Think about how you created your square in Task 4. The 8 commands can be
split into pairs, where the pair of commands are repeated 4 times.

To repeat commands in XLogo you use “repeat 4 [fd 100 rt 90]” which will repeat the
program in the square brackets four times. Try out the above command and confirm that it
creates the same square as Task 4.

Repeating code allows you to break down the pattern you are trying to create into a
smaller pieces and then repeat this smaller pattern to create the final pattern.

6. Stairs

Create a program which creates a staircase consisting of 10 steps of size 20.


• First find the repetitive pattern
• Think about how to move the cursor in the correct direction.

7. Stars

Draw an 8 point star with the angle between each point at 45 o and the length of
the points are 250 steps.

By default the cursor will create a line over


every step it takes. You can stop this by using
the “penup” command and return it to default
using the “pendown” command.

3
LOGO
O n c e yo u h ave w r i t t e n a p r o g r a m (a s e t o f
commands) you may want to reuse this program
again. You can do this by naming the program and to SQUARE100
calling it using its name. This process of naming and repeat 4 [fd 100 rt 90]
reusing code is referred to in industry as creating
functions. The code on the right will make a
end
function called “SQUARE100” which when called
will create a square with sides of size 100.

8. STEP 20

Create a program called STEP20 which creates one step from the stair in Task 5.
Use this program to create the stairs from Task 6.

9. Street

Create a program which draws a row of houses.


• First create a program which creates a house.
• Use this program and the repeat command to create the row of houses.
• Remember to make a gap between each house!

So far we have looked at creating squares within XLogo but it is also possible to create all
type of regular polygons. If we think about a regular polygon with 10 corners and sides,
how much do you need to turn at each corner?

If you start at one corner of a polygon facing north, after walking through each of the sides
of the polygons you will return facing north, hence you have moved through 360 o .
Therefore at each corner of a 10-sided polygon you need to turn:

360 0 = 36 o
10
10. Shapes

Create a program which creates a 5 sided shape, a 7 sides shape and a 9


sided shape.

Create these as their own programs called SHAPE5, etc.

4
LOGO
11. Shapes

Create a program that creates a circle.

(It is not possible to make a perfect circle, but a shape that resembles a
circle)

A program that will create a 10-sides polygon can look this this: “repeat 10 [ fd 50 rt 36]”.

It is also possible to change the colour of the pen used when creating lines. You can do
this by using the “setpencolour x” or “setpc x” where “x” is the colour number which you
can find on the back of this workbook.

Within programs it can be very useful to store a value and refer to it by a certain name
for the rest of the program which are commonly referred to as variable. Within XLogo
we can use variables as an input into our programs. Think back to Task 10 where we
created separate programs for each regular polygon we wanted to create. By using
variables we can create one program that will draw any number of sided polygon.

12. House

Create a program which creates a house (similar to that in Task 9) which


has sides of the size specified when the program is called.

13. Row of Houses

Using the program created in Task 12, create a row of houses that has the
number of houses specified and the size of the houses specified.

To create a program which takes a variable as input which will create a polygon with the
number of sides specified you use the following code:

to POLYGON :SIDES
repeat :SIDES [fd 50 rt 360/:SIDES]
end

5
Command Cheat Sheet
Command Shor tcut Description
Move the cursor forward x
forward x fd x
number of steps.

Move the cursor backwards x


back x bk x
number of steps.

Turns the cursor x degrees to


right x rt x
the right.

Turns the cursor x degrees to


left x lt x
the left.

This will repeat the commands


repeat x [Program] NA within Program x number of
times.

Lifts the cursor up / down so


penup / pendown pu / pd that moving the cursor will not
create a line when the pen is up.

to NAME Creates a program called NAME


Program NA which when called will run the
end commands within Program.

Sets the colour of the pen as


the specified colour x. For
setpencolor x setpc x
values of x see colour chart
overleaf.

Creates a program called NAME


to NAME :X
which takes in the variable
Program NA
called X. You can use the
end
variable X within the program.

Creates a program called NAME


to NAME :X :Y which takes in the variables
Program NA called X and Y. You can use the
end variable X and Y within the
program.

penerase / Set the pen to erase / paint


pe / ppt
penpaint mode.

The cursor will wait x seconds


wait x NA before moving on to the next
command.
6
hideturtle /
ht / st Hides / shows the cursor.
showturtle
Colour Chart

Number Primitives [R G B] Colour


0 black [0 0 0]
1 red [255 0 0]
2 green [0 255 0]
3 yellow [255 255 0]
4 blue [0 0 255]
5 magenta [255 0 255]
6 cyan [0 255 255]
7 white [255 255 255]
8 gray [128 128 128]
9 lightgray [192 192 192]
10 darkred [128 0 0]
11 darkgreen [0 128 0]
12 darkblue [0 0 128]
13 orange [255 200 0]
14 pink [255 175 175]
15 purple [128 0 255]
16 brown [153 102 0]

www.technocamps.com

You might also like