Catalog / Logo Programming Language Cheatsheet

Logo Programming Language Cheatsheet

A concise cheat sheet for the Logo programming language, covering basic commands, syntax, and concepts. Perfect for beginners learning turtle graphics and fundamental programming principles.

Basic Commands

Movement

FORWARD fd or FD fd

Moves the turtle forward by fd units.

BACK bk or BK bk

Moves the turtle backward by bk units.

RIGHT rt or RT rt

Rotates the turtle clockwise by rt degrees.

LEFT lt or LT lt

Rotates the turtle counter-clockwise by lt degrees.

PENUP or PU

Lifts the pen, so the turtle moves without drawing.

PENDOWN or PD

Lowers the pen, so the turtle draws as it moves.

HOME

Returns the turtle to the center of the screen, pointing upwards.

CLEARSCREEN or CS

Clears the drawing area.

Pen Control

SETPENCOLOR color or SETPC color

Sets the pen color. color can be a number or a color name (e.g., RED, BLUE).

SETPENSIZE size

Sets the pen size to size. Example: SETPENSIZE [5 5]

FILL

Fills a closed shape with the current pen color.

Turtle Visibility

SHOWTURTLE or ST

Makes the turtle visible.

HIDETURTLE or HT

Hides the turtle.

Control Structures

Repetition

REPEAT count [ commands ]

Repeats the specified commands count times.

Example:

Draws a square.

Conditionals

IF condition [ commands ]

Executes the commands only if the condition is true.

Example:

IFELSE condition [ commands_true ] [ commands_false ]

Executes commands_true if the condition is true, otherwise executes commands_false.

Example:

Variable Assignment

MAKE "variable value

Assigns value to the variable named variable.

Example:

THING "variable

Retrieves the value of a variable.

Example:

Procedures

Defining Procedures

Use TO procedure_name to start a procedure definition and END to finish it.

Calling Procedures

Call a procedure by simply typing its name followed by any required arguments.

Example Procedure with Parameters

Math and Logic

Arithmetic Operators

+

Addition

-

Subtraction

*

Multiplication

```

Division

%

Modulo (remainder)

Comparison Operators

>

Greater than

<

Less than

=

Equal to

Random Numbers

RANDOM limit

Generates a random integer between 0 and limit - 1.

Example: