Turtle Lab

MCA · Friday Enrichment · Python

my_drawing.py
Ctrl+Enter runs
Ready

The turtle starts at (0, 0) in the center, facing right. Each grid square is 50 steps.

Output
Anything you print() shows up here.
Turtle cheat sheet

Moving and drawing

forward(100)Move forward 100 steps
backward(50)Move backward
left(90) / right(90)Turn in degrees
penup() / pendown()Stop or start drawing while moving
goto(100, -50)Jump to a point (x, y)
circle(60)Circle with radius 60
color("red")Pen color. color("navy", "gold") sets pen and fill
pensize(5)Line thickness
begin_fill() … end_fill()Fill the shape drawn in between
speed(0)0 is fastest, 1 is slowest, 10 is fast
hideturtle()Hide the arrow

From the robot game to Python

FORWARD 2forward(100)
TURN LEFTleft(90)
TURN RIGHTright(90)
REPEAT 4 [ … ]for i in range(4): then indent the lines inside

Common bugs

Spellingforward, not foward or Forward
Colonfor and def lines end with :
IndentLines inside a loop start with 4 spaces (press Tab)
QuotesColors need quotes: "red". Numbers don't.