MSW Logo Intro
MSW Logo Intro
UNIT OUTCOME
Students will be able to:
understand the logo language;
recognize to produce a variety of diagrams using the logo language.
Starting LOGO
To start L O G O , perform the following steps:
Click S ta rt → Al l P rog ra m s → M i c rosof t W i n d ow s L og o → M i c rosof t W i n d ow s L og o
(see Fig. 6 .1 ).
The turtle moves on the screen according to the commands given. It understands only LOGO
commands. Centre of the screen is the home of the turtle.
l Using Primitives
W hen you load L O G O , a triangular shape pointer appears at the centre of the screen called Turtle.
It has a pointing tip. Turtle indicates that position on the screen, from where the drawing will
start. In other words, we can say that turtle is a point of invisible pen, that helps in drawing
figures. The home position of turtle is in the centre of the screen, where it appears in the beginning.
The primitives are typed in the white space at the bottom left corner of the screen known as the
Command Input B ox.
The first step to learn any drawing is to know about drawing a line. Therefore, you will read
about some primitives which are useful in drawing lines and boxes.
Information Communication Technology — Grade 9 Student Textbook 119
Unit – 6 Control and Learning with LOGO
Forward (FD)
This primitive moves the turtle in the forward direction with the number of steps mentioned with
the primitive. The turtle draws a line while moving. For example, to draw a line of 4 0 steps type
the following command in the Input B ox.
C O M M AN D R E S U L T
Back (BK)
Turtle moves backward and draws a line of specified number of steps.
The turtle moves in the direction, where it has its back.
It is just like driving a car in reverse (back) gear.
For example, to draw a line of 50 steps in backward direction, type the following command in the Input
B ox.
C O M M AN D R E S U L T
R i g ht ( R T )
To turn the Turtle in right or clockwise direction, use RT/ RIGH T primitive. It needs number of degree to
know the angle of turn. For example,
L fe t ( L T )
To turn the Turtle towards left or in anti-clockwise direction, use LT/ LEFT primitive. It needs number of
degree to know the angle of turn. For example,
W e can move the turtle forward, backward, right and left on the screen.
Home
Turtle always rests in the centre of the screen which is known as its home. From here, the turtle moves
around the screen.
H OM E primitive sends the turtle in the centre of the screen. The H OM E primitive is not followed by
any number. The turtle draws a line as it goes back to its home and faces upwards in its home position.
For example,
Type the following commands in the Command Input B ox to see the output shown on right side:
FD 10 ↵
RT 90 ↵
FD 10 ↵
H OM E ↵
H i d e T urtl e ( H T )
W h en this command is entered, the turtle disappears from the screen.
Turtle follows all the commands and can draw anything even though it is not seen on the screen. For
example,
1. N o space(s) is/ are required within a primitive. If you give space, error message appears.
2. To use more than one primitive at a time, we must leave a space in between them.
S how T urtl e ( S T )
ST command brings the turtle back on the screen, which had disappeared using H T command. For
example,
C l ear T ext ( C T )
It clears the Text A rea.
A ll the commands disappear from the Listener window. For example,
C l ear S c reen (C S )
CS command clears the Graphics area. For example,
CLEA N command clears the entire drawing from the screen but leaves the turtle at its last position.
P en U p (P U )
A s you lift your pencil up when you want to leave some gap between the two words while writing, so is
the case with the turtle.
To move the turtle without drawing a line PE N U P primitive is used. There is no need to give any
number after P EN U P command. For example, to draw the two lines shown on left, type the commands
shown on right side.
In the above example, we have used PD command, let us see why this command has been given.
P ne D ow n ( P D )
Y ou cannot draw till you put your pencil down. The same way, turtle starts drawing again only when
you give P EN DOW N (P D) command. There is no need to mention any number after P D command. For
example,
P ne E ras e ( P E )
The turtle can erase a line on which it moves. For this P EN ERA SE (P E) primitive is used. Y ou need to move the
turtle on the lines you want to remove/ erase after giving P E command. For example,
To erase a line of 10 steps so that this figure can become a square of 40 steps, give the following
commands:
To bring your turtle in the normal mode again, give PE command so that you can complete your figure
after correcting the mistake.
Type the following command in the Command Input B ox to create a circle of radius 8 0 with the turtle
at the edge of the circle:
CIRCLE2 80 ↵
P ri n t C om m an d
P RIN T/ P R primitive is used to display a letter, number, word or a sentence on the screen. It can also
be used for doing calculations. This command takes only one input at a time and displays the output in
Recall List B ox. For example,
P RIN T 201 ↵
R pe eat C om m an d
REP EA T primitive is used when same set of commands are to be given again and again. Instead of
typing same set of commands repeatedly, they can be clubbed up in a single line REP EA T command. For
example, to draw a square of side 6 0 steps, type the following command:
OR
H ere, the number 4 after the REP EA T primitive, tells the computer to repeat four times whatever
command is given within the square bracket.
The structure of REP EA T command is:
JN o. of turtle steps in N
N o. of times
K each line direction and O
REP EA T the commands are
K O
KK the angle by which
to be repeated OO
L turtle turns each time P
N ow, type the following command in the Command Input B ox to draw the regular polygons (pentagon
and hexagon) by using the REP EA T command:
For an N side regular polygon, the Turtle will turn by 360/ N degrees.
Procedures
Pr ocedures are the heart of LOGO and other programming languages. Pr ocedures are small programs that
can be called on again and again through one word and without typing them all out.
The structure of a procedure in LOGO is:
To Procedurename
Steps of the procedure
End
A procedure must start with the word To, followed by a name you give. Then come all the steps you
would write on the command line. A procedure must end with the word End.
Random Command
LOGO provides one of the best ways of stimulating children in their work by using the RA N DOM command.
The command RA N DOM is usually followed by a number. For example,
RA N DOM 1 5 ↵
would generate a random integer number less than 15.
Type the following and see the output:
REP EA T 5 [SH OW RA N DOM 100] ↵
H ow d o y ou w ri te a p roc ed ure i n L O G O ?
A LOGO procedure can be written in the following ways:
1. U sing the Input B ox (see Fig. 6.4) , which can be opened
by typing in TO followed by the Pr ocedure N ame in the
Command Input B ox.
2. U sing the Editor window (see Fig. 6. 5) , which can be opened
Fig. 6.4: User Input Box
by any one of the following:
(i) Clicking the Edall button on the Button bar
(ii) U sing the Edit option in the File menu
(iii) Typing “ Edit Pr ocedure N ame in the Command Input B ox (do not forget quotation mark before
Pr ocedure N ame).
Let us write a simple procedure S Q U AR E in LOGO, using the I n p ut B ox , to draw a square of side of
length 50.
To code, run and save the procedure, perform the following steps:
1. Click the I n p ut B ox .
2. Type in T O followed by the name of the procedure, here we type, T O S Q U AR E .
3. Pr ess the Enter key. The user I n p ut B ox appears.
4. Enter the set of instructions one after other for drawing a square. Pr ess the Enter key after each
line.
5. Wh en all the instructions have been entered, type in E N D and press the Enter key. Y our Pr ocedure
S Q U AR E has been defined. The entered procedure code is shown below:
TO SQ U A RE
; Pr ocedure SQ U A RE
CS ; Clear Screen
REPEAT 4 [FD 50 RT 90]
H T ; H ide Turtle
EN D
6. To run the procedure, type S Q U AR E in the C om m an d I n p ut B ox and press the Enter key.
This draws a square of side length 5 0 on the graphics screen as shown below:
In LOGO, you can put a procedure within REPE A T command or within another procedure. Let us write
procedures to include REPE A T and RA N DOM command:
E xam p l e 1: Wr ite a procedure to draw a simple star shape using REPE A T command.
TO STA R
; Pr ocedure STA R
CS ; Clear Screen
REPEAT 10 [LT 60 FD 50 RT 120 FD 50 LT 60 RT 36]
H T ; H ide Turtle
EN D
Type the following in the Command Input B ox and press the Enter key to run the procedure:
STA R
Y our output may be different every time when you run the LOGO procedure(s) having RA N DOM
command(s).
E xam p l e 3: Wr ite procedure(s) to draw squares randomly using RA N DOM command.
Let us write a procedure SQ U A RE1 first and then use it in another procedure RSQ U A RES to draw
random squares:
TO SQ U A RE1
; Pr ocedure SQ U A RE1
REPEAT 4 [FD 40 RT 90]
HT ; Hide Turtle
EN D
TO RSQ U A RES
; Pr ocedure RSQ U A RES
CS ; Clear Screen
REPEAT 30[SQUARE1 PENUP RT RANDOM 360 FD RANDOM 50 PENDOWN]
EN D
Type the following in the Command Input B ox and press the Enter key to run the procedure:
RSQ U A RES
This will draw random squares on the screen, lifting the pen and moving it to a random location before
drawing another square as shown below:
Type ERA SE “Pr ocedure N ame and press Enter key to erase a procedure. The ERA SE A LL command
erases all the procedures.
Activity 6.1
DRAW A VARIET Y OF SHAPES USING THE LOGO PRIMITIVES AND PROCEDURES
Students in small groups will use the LOGO primitives and procedures to draw a variety of shapes. The group
leader from each group will give a brief presentation to the class based on it.
LOGO Primitives
The LOGO Primitives are basic LOGO Commands.
Procedures
Procedures are small programs that can be called on again and again through one word and without typing
them all out.
A S q uar e TO Square
; This procedure will draw a square
CS
REPEAT 4[FD 100 RT 90]
HT
END
KEY CONCEPTS
LOGO stands for Logic Oriented, Graphics Oriented.
MSW LOGO screen is divided in two parts—Graphics window and Listener window.
CS primitive clears the graphics screen.
We can write a procedure in two ways using the “Input Box” or using the “Editor window”.
Procedures are small programs that can be called on again and again through one word without typing them
all out.
The file saved in LOGO will have an extension .LGO.
BYE primitive closes the LOGO.
Review Questions
Fill in the Blanks
1. LOGO was developed by ...................... and his team.
2. Wh en you load Logo, a triangular shape pointer appears at the centre of the screen called .................... .
3. The ...................... primitive moves the turtle in forward direction.
4. The ...................... primitive turns turtle’ s face on left side.
State Whether True or False
1. Logo is a high-level programming language.
.2 Logo is considered an interpreted language because Logo programs are executed by an interpreter.
.3 The B K primitive turns turtle face on right side.
.4 The ST primitive shows the turtle again.
Multiple Choice Questions
1. A ll the figures are drawn by ...................................... in LOGO.
(a) Turtle (b) H and
(c) B ye (d) Pr int
2. Wh ich of the following LOGO primitive moves the turtle’ s face in right side?
(a) ST (b) H OM E
(c) PD (d) RT
132 Information Communication Technology — Grade 9 Student Textbook
Unit – 6 Control and Learning with LOGO
3. Wh ich of the following LOGO primitive moves the turtle in backward direction?
(a) FD (b) B K
(c) H T (d) B Y E
4. A set of LOGO commands referred by a name, which is given to perform a particular task is called a .
..................................... .
(a) Operator (b) Pr ocedure
(c) A ction (d) Random
Column A Column B
1. Graphics window in LOGO (a) Generates a random integer number
2. Listener window in LOGO (b) U sed to exit LOGO
3. B Y E primitive (c) The area where the commands are typed
4. Random command (d) The area where the turtle moves and draws
3. Wh at are LOGO primitives? Explain any four LOGO primitives to draw shapes.
4. Wr ite a procedure using RA N DOM command in LOGO.
Suggested Activities
1. Wr ite a procedure to draw an equilateral triangle.
2. Wr ite a procedure to include a random number generator e.g., throwing a die.
3. U se Full version of LOGO language.
GLOSSARY
A D at a C om m un i c at i on s: The moving or sharing
of encoded information between two or more data
AI ( Arti f i c i al I n tel l i g en c e) : It is the branch of sources using an electronic medium.
computer science concerned with making computers
behave like humans. D i stri b uti on L i st: A lso called a mailing list, is a
collection of e-mail addresses that allows you to e-mail
An al og : It is any fluctuating, evolving, or
multiple people at one time.
continually changing process that represents data by
measurement of a continuous physical variable. D V D : Digital V ersatile Disc or Digital V ideo Disc.
Ap p l i c at i on S of tw ar e: A program that is designed
to perform specific tasks. E
AS C I I : A merican Standard Code for Information E - C om m er c e: B uying and selling or business
Interchange. It is pronounced (as-kee). transaction conducted on the Internet.
B E - M ai l : Stands for Electronic M ail. This is a system
of relaying messages across the Internet, from one
B ac k up : To copy files or data to a second source or Internet user to another.
media so as to safeguard it.
B C D : B inary Coded Decimal. F
B I T ( B i n ar y D i g I T ) : It is the smallest unit of F orm at P ai n ter : H elps to copy the format that has
processing of computerized data in terms of 1s or 0s .
been applied to text and apply it to another.
B row ser : Software program that allows the user to
find and read encoded information in a form suitable F T P ( F i l e T ran sf er P rotoc ol ) : A software protocol
for display especially on Wo rld W ide W eb. for exchanging information between computers over a
network.
B y te: A combination of 8 bits to represent computer
data transfer or data storage measurement.
G
C G i g ab y te ( G B ) : 2 to the 30t h power (1,073,741,824)
C D -R O M ( C om p ac t D i sc R ead - O n l y M em ory ) : bytes. One gigabyte is equal to 1,024 megabytes.
A durable and low cost circular optical storage device G I G O : It is an acronym that stands for Garbage In,
widely used to store large amounts of information. Garbage Out.
C om p uter : A computer is an electronic device that
accepts, processes, stores and outputs data under the H
control of a set of instructions.
C P U ( C en tral P roc es si n g U n i t) : A processor on H ar d w a re : The physical equipment used in a
an IC chip (called a microprocessor) that serves as the computer system, such as the CPU , peripheral devices
and memory.
‘ brain’ of the computer.
H om e P ag e: The initial page of a site on the Wo rld
W ide W eb.
D
H T M L ( H y p er text M ar k up L a n g uag e) : It is a
D at a: A collection of raw facts and figures or a collection of structuring and formatting tags used to
raw input which when processed or arranged makes create W eb pages.
meaningful output.
134 Information Communication Technology — Grade 9 Student Textbook
Glossary