Logo Tutorial
Logo Tutorial
Writing computer programs is not easy. There are programs which has millions of
commands. To keep track of such a complicated program, it is very important to approach
the task of writing a program in a structured and well-thought-out manner. This is what
we will learn in this Logo programming course.
Audience
This tutorial is designed for those readers, who seek to understand the basic concepts of
writing programs in Logo programming language and how its different commands function.
Prerequisites
There are no prerequisites for this tutorial, except for a wish to learn how a computer
program works. Having basic computer operating knowledge will be an added advantage
in understanding this tutorial.
All the content and graphics published in this e-book are the property of Tutorials Point (I)
Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish
any contents or a part of contents of this e-book in any manner without written consent
of the publisher.
We strive to update the contents of our website and tutorials as timely and as precisely as
possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt.
Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our
website or its contents including this tutorial. If you discover any errors on our website or
in this tutorial, please notify us at [email protected]
i
Logo
Table of Contents
About the Tutorial ............................................................................................................................................ i
Audience ........................................................................................................................................................... i
Prerequisites ..................................................................................................................................................... i
Copyright and Disclaimer ................................................................................................................................. i
Table of Contents ............................................................................................................................................ ii
8. Logo – Randomization............................................................................................................................. 23
ii
1. LOGO – INTRODUCTION Logo
Logo is a programming language that is very simple and easy to learn. It is used for teaching
students and children how to program a computer.
Logo is a very easy and interesting programming language to learn. It has enough depth to
virtually do anything, which can be done in any other computer programming language.
www.softronix.com/mswlogo.html
3
Logo
We will write commands in the command line, i.e., the text box at the bottom of the
Commander Window. To execute or run these commands, press Enter or click the Execute
Button. We can also write and run more than one command online at a time.
The command history will appear in the gray box. Click a line in the history to make it jump
to the respective command line, then we can make changes (if required). Once this is done,
press Enter or click the Execute Button.
4
2. LOGO – TURTLE Logo
The simple Logo Drawing Commands move the Turtle forward and backward and also turn it
right or left. The commands and their abbreviations are given below:
fd – forward
bk – backward
rt – right
lt – left
cs – clearscreen
Either version of these commands can be used. Except the cs command, each of these
commands must be followed by one value called as its argument. The arguments for fd and
bk are units; those of rt and lt are angles that can be any integer. A rotation by 360 is a
complete rotation, therefore a rotation by 375 degrees is the same as 1/15 degrees.
clearscreen or cs means erase all drawings. This sets the turtle at the center
The graphics window has a coordinate system. The values of the two coordinates (normally
called x and y) at the center are 0, 0. At the northeast corner, they are 250, 250; at the
southeast corner, they are 250, -250. At the southwest corner, they are -250, -250; etc. If
the turtle tries to walk off onto one side of the screen, it wraps around. The right side wraps
to the left side and the top wraps to the bottom.
Many programming systems work on the same kind of two-axis ‘xy’ coordinate plane, which
we work with in Algebra as well.
5
Logo
Here, ‘0 0’ is the center, or origin (no comma or parentheses here!). In its centered,
zoom-"normal" state, Logo's drawing screen shows an area of about 150 points up or down
and 300 points right or left from the center.
The turtle can be directed with headings that correspond to a compass rose, with 0 or 360
degrees pointing straight up, 90 degrees straight to the right, and so on. You can set a variable
to a number between 0 and 360 and then walk on that path.
Turtle Commands
Now let us try some commands. Commands will be issued one per line followed by a carriage
return. Several of these commands can be typed in succession in a command window followed
by a carriage return. The effect on the turtle is the same. However, if you type a command,
which requires one or more inputs and provide the missing input(s) on the next line, Logo will
show an error.
Following is a practice command, which shows the desired results on the right.
6
Logo
The commands – fd 50 rt 120 fd 50 rt 120 fd 50 rt 120, cause the turtle to draw a triangle,
as you can see by trying them out.
These commands are read from the left to the right. Since the command fd requires one
argument, it is taken as the next value. Similarly, rt takes an argument as well. Thus, Logo
can give an unambiguous meaning to each of these character strings. For some Logo
commands, separators are needed.
7
Logo
Following are few practice commands with the desired results on the right.
8
Logo
Following is an exercise to check your aptitude on what you have learned so far in this chapter.
9
Logo
10
Logo
11