A SIMPLE COMPUTER LANGUAGE LOGO. LOGO Introduction Logo is the simplest programming language. It

Preview:

Citation preview

A SIMPLE COMPUTER LANGUAGE

LOGO

LOGO Introduction

http://pages.intnet.mu/jhbpage/Program/Logo/logo.htm

Logo is the simplest programming language. It was developed by Seymour Papert in 1968. It was developed originally as a teaching tool. 

Though Logo is a complete language it is mainly used for drawing.

The Logo Environment

Basic Logo Commands

Instruction Shortcut Description

SHOWTURTLE ST Shows the Turtle on the screen

HIDETURTLE HT Hides the Turtle from the screen

FORWARDnumberFD Moves the Turtle forward according to the number indicated

BACK number BK Moves the Turtle back according to the number indicated

RIGHT angle RT Changes the direction of the Turtle by turning it to the right

LEFT angle LT Changes the direction of the Turtle by turning it to the left

CLEARSCREEN CS Erase the picture before a new picture is drawn

How to draw a 100 by 100 square in Logo?

Step 1

FORWARD 100

Step 2

RIGHT 90

How to draw a 100 by 100 square in Logo?

Step 3

FORWARD 100

Step 4

RIGHT 90

How to draw a 100 by 100 square in Logo?

Step 5

FORWARD 100

Step 6

RIGHT 90

How to draw a 100 by 100 square in Logo?

Step 7

FORWARD 100

Step 8

HIDETURTLE

Procedures

A procedure has 3 parts:1.It must start with the reserved word “TO”, followed by a one word procedure name.2.The main body is made up of primitives3.The procedure ends up with word “END”

A Scalene Triangle

TO scaleneCSFD 100 RT 150FD 50HOMEHTEND

An Isosceles Triangle

TO isoscelesCSRT 20FD 100 RT 140FD 100HOMEHTEND

A Pentagon

TO pentagonCSFD 100 RT 72FD 100 RT 72FD 100 RT 72FD 100 RT 72FD 100 RT 72HTEND

Looping

TO pentagonCSFD 100 RT 72FD 100 RT 72FD 100 RT 72FD 100 RT 72FD 100 RT 72HTEND

TO pentagonCSREPEAT 5 [FD 100 RT 72]HTEND

A Rectangle

TO rectangleCSFD 100 RT 90FD 50RT 90FD 100 RT 90FD 50RT 90HTEND

A Rectangle

TO rectangleCSFD 100 RT 90FD 50RT 90FD 100 RT 90FD 50RT 90HTEND

TO rectangleCSRepeat 2 [FD 100 RT 90FD 50RT 90]HTEND

An Equilateral Triangle

TO equilateralCSFD 100 REPEAT 2[RT 120FD 100]HTEND

TO equilateralCSFD 100 RT 120FD 100 RT 120FD 100 HTEND

A Kite

TO kiteCSFD 90BK 30RT 90FD 30BK 60LT 45FD SQRT (2*(30*30))RT 90FD SQRT (2*(30*30))HOMEFD 60LT 90FD 30HOMEEND

A Kite

TO kiteCSFD 90BK 30RT 90FD 30BK 60LT 45FD SQRT (2*(30*30))RT 90FD SQRT (2*(30*30))HOMEFD 60LT 90FD 30HOMEEND

Loop and Double Loops

Try each of the following:(Reset the screen before each try)1.FD 50 RT 452.REPEAT 4 [ FD 50 RT 45 ]3.REPEAT 8 [ FD 50 RT 45 ]4.REPEAT 2 [REPEAT 8 [ FD 50 RT 45 ] RT 45] 5.REPEAT 3 [REPEAT 8 [ FD 50 RT 45 ] RT 45]6.REPEAT 4 [REPEAT 8 [ FD 50 RT 45 ] RT 45]7.REPEAT 8 [REPEAT 8 [ FD 50 RT 45 ] RT 45]

Double Loops

TO NREPEAT 8 [REPEAT 8 [ FD 50 RT 45 ] RT 45] END

Loop

REPEAT 12 [ FD 100 RT 150 ]

Double Loops

REPEAT 72 [ REPEAT 360 [ FD 1 RT 1 ] RT 5 ]

Double Loops

TO CPERSPECTIVEREPEAT 4 [REPEAT 4 [FD 100 RT 90] FD 100 DOWN 90END

Double Loops

TO RPERSPECTIVEREPEAT 45 [ REPEAT 360 [ FD 2 RT 2 ] RR 8 ]END

Basic Logo Commands

Instruction Shortcut Description

PU Pen Up

PD Pen Down

PPT Pen Paint

SETXT num1 num2

SETXY Moves the Position X, Y

Recommended