25
A SIMPLE COMPUTER LANGUAGE LOGO

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

Embed Size (px)

Citation preview

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

A SIMPLE COMPUTER LANGUAGE

LOGO

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

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.

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

The Logo Environment

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

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

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

How to draw a 100 by 100 square in Logo?

Step 1

FORWARD 100

Step 2

RIGHT 90

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

How to draw a 100 by 100 square in Logo?

Step 3

FORWARD 100

Step 4

RIGHT 90

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

How to draw a 100 by 100 square in Logo?

Step 5

FORWARD 100

Step 6

RIGHT 90

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

How to draw a 100 by 100 square in Logo?

Step 7

FORWARD 100

Step 8

HIDETURTLE

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

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”

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

A Scalene Triangle

TO scaleneCSFD 100 RT 150FD 50HOMEHTEND

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

An Isosceles Triangle

TO isoscelesCSRT 20FD 100 RT 140FD 100HOMEHTEND

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

A Pentagon

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

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

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

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

A Rectangle

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

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

A Rectangle

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

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

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

An Equilateral Triangle

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

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

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

A Kite

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

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

A Kite

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

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

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]

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

Double Loops

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

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

Loop

REPEAT 12 [ FD 100 RT 150 ]

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

Double Loops

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

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

Double Loops

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

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

Double Loops

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

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

Basic Logo Commands

Instruction Shortcut Description

PU Pen Up

PD Pen Down

PPT Pen Paint

SETXT num1 num2

SETXY Moves the Position X, Y