Learn to Code via Tutorials on Repl.it!

← Back to all posts
A Crash Course In Python Turtle!
JWZ6 (710)

Hi Everyone!

Me and @SamiOsman will be teaching you Python Turtle today! I've seen many Python Turtle tutorials and they aren't exactly the best. Anyways, here it is! A good Python Turtle tutorial is here.

This is definitely not boring (100% true).

Table Of Contents

  • Getting Started
  • Turtle Movement
    • Drawing
      • Introduction
      • Circles And Dots
      • Stamp
      • Making Polygons
    • Positioning
      • Goto
      • Setposition
    • Writing
  • Drawing
    • Color
    • Filling
      • Begin Filling
      • End Filling
    • Pen Visibility
      • Show Turtle
      • Hide Turtle
    • Other Drawing Methods
      • Turtle Speed
      • Turtle Shape
      • Turtle Size
      • Turtle Pen Color
  • Events
    • Onkey
    • Ontimer
    • Onclick
      • Python
      • Python(with Turtle)
  • Window
    • Background
      • Bgcolor
      • Bgpic
      • Reset
    • Input
      • Text Input
      • Number Input
    • Exiting
      • Exit
      • Exit Onclick
    • More Window Methods
      • Setup
      • Title
    • Ending

Getting Started

First, open up a new project. You can do it in either Python or Python(with Turtle). Next, do:

# Importing The Turtle Module
import turtle
# Giving The Turtle Project A Title
turtle.title("Turtle Project")

The turtle.title() won't work if your using Python(with Turtle). You can rename the turtle title. Just be careful and don't get any errors.

Turtle Movement

Drawing (Introduction)

Lets start off by doing turtle.forward(30). This will make the turtle move forward. The number in the () is the amount you want it to go forward. You also have turtle.backward(), turtle.left(), turtle.right(), turtle.up(), and turtle.down. No need for an explanation on how they work. For example, you could have:

# Importing The Turtle Module
import turtle
# Moving Forward
# Turning Left 40 Degrees
# Moving Backwards
# Turning Right 80 Degrees
# Turnin

Negatives also work. The numbers inside the () have to be integers or floats. No strings

Drawing (Circles And Dots)

If you want a circle, do turtle.circle(radius). The radius of the circle goes inside the (). If you use turtle.dot(radius, color), you would get a dot. The differences between the circle and the dot are that the dot would be filled by the color, but the circle wouldn't be. The middle of the dot is the turtle cursor, but the edge of the dot is the cursor. For example, you might have:

# Importing The Turtle Module
import turtle
# Making a circle with a radius of 20
# Making a dot with the color of blue and the radius of 30

Drawing (Stamp)

By using turtle.stamp(), you imprint the turtle shape onto the turtle canvas, wether it's triangle or classic (I'll get to that later). If you don't want the stamp, just don't use it. It looks like this:

# Importing The Turtle Module
import turtle
# Making A stamp

Making Polygons

To begin a polygon, use turtle.begin_poly(). To end one, use turtle.end_poly(). I'm not exactly sure why there's a begin/end polygon function. If you use it, do:

# Importing The Turtle Module
import turtle
# Using turtle.begin_poly()
# Moving forward
# Ending The Polygons


You can position the turtle pen by using turtle.goto(). or you can use setposition(). They're the same thing. By using turtle.goto() , the turtle pen will teleport the turtle to the exact coordinates that you give inside the (). If you put two coordinates then do x, y. Remember, x comes first, not y. For example, you could have:

# Importing The Turtle Module
import turtle
# This will go to the position of 45(x), 4(y) coordinates
turtle.goto(45, 4)


You can write text by using using turtle.write("text"). For example, you could have:

# Importing Turtle Again
import turtle
# Using turtle.write()



You can change the color by using turtle.color(color). That way you can change the turtle color while you are drawing. Look to Turtle Movement for how to do that. For example you might have:

# Importing The Turtle Module
import turtle
# Changing The Color
# Using The For Loop
for i in range(4):
  # Moving Forward
  # Turning Left


(You have to make a shape before the shape can be filled).

You can start filling by using turtle.begin_fill(). You end the filling by doing turtle.end_fill(). The last color you use before the turtle.end_fill() will be the fill color. For example:

# Importing The Turtle Module
import turtle
# Specifying the color
# Starting the fill
# Making the circle
# Stopping the fill

Pen Visibility

You can either hide the pen or show the pen in Python Turtle. You can hide the turtle pen by using turtle.hideturtle(). Use turtle.showturtle() to show the pen. For example, you might use:

# Importing The Turtle Module
import turtle
# Hiding The Pen
# Drawing A Circle
# Showing The Pen

Other Drawing Methods

Turtle Speed

You can change the speed of how quick the turtle pen is moving by using turtle.speed(). The number range inside the () has to be 0-10. 0.5-0 shows no movement unless you change the turtle speed later on. 1 means very slow while 10 means fast. For example, you could have:

# Importing The Turtle Module like I always do
import turtle
# Changing The Speed
turtle.speed(10) # Fast
# Changing the color
# Moving Forward

Turtle Shape

There are 6 different types of turtle shapes: classic, arrow, square, circle, triangle, and turtle. You can use those shapes in turtle.shape(shape). For example, you could have:

# Importing The Turtle Module Like I Always Do
import turtle
# Changing The Shape

Turtle Drawing Size

You can change the turtle drawing size by using turtle.pensize(). The number inside the () must be in between 1-10. 1 is very thin but 10 is thick. For example, you might have:

# Importing The Turtle Module Again
import turtle
# Changing The Drawing Size
# Drawing A Thick LLine

Turtle Pen Color

You can change the pen color by using turtle.pencolor(""). In the quotation marks put the color that you want the turtle to be. This will not change the drawing color, only the pen color. For example you could have:

# I Always Do This
import turtle
# Changing the PEN color
# Changing the DRAWING color
# Casually Drawing a Straight Line



This will not work for mobile or Python(with Turtle)

Using turtle.onkey(function, "key") will detect if a number, arrow key, or letter is pressed. For arrow keys, use "Up", "Down", "Left", and "Right". This does not work for other keys (like space). The same works for numbers. You could have:

# Importing Turtle
import turtle
# methods with different work
# at different keys
def one():
  # Writing One20
# Using Onkey
turtle.onkey(one, "1")
# Using Onkey Again
turtle.onkey(one, "o")
# Using Onkey Once Again
turtle.onkey(one, "Up")
# Waiting For The Key 1 Or O To Be Pressed

You must end with a turtle.listen() to make onkey work.


This only works in Python

turtle.ontimer(function, t=0) means that it executes the function after the t = (t in milliseconds). You don't need to use turtle.listen(). For example you could have this:

# Importing Turtle Again
import turtle
# Creating A function
def func():
  # Using turtle.write()
# Using Ontimer
turtle.ontimer(func, t = 500)



By using turtle.onclick(function (), btn=1, add=None). It will execute the function(). btn=1 means the number of times the user has to click in order to execute the function. add=None means that if it is True, a new binding will be added, and if it is False it will replace a former binding. For example you could have:

# Importing Turtle Again
import turtle
# Creating A function
def func():
  # Using turtle.write()
# Using Onclick
turtle.onclick(func(), btn = 1, add = None)

Python (with Turtle)

Using onclick in Python(with Turtle) is simpler than using onclick in Python. The syntax looks like turtle.Screen.onclick(function). For example, you might have

# Importing Turtle Again
import turtle
# Creating A function
def func():
  # Using turtle.write()
# Using Onclick



This does not work for Python(with Turtle)

By using turtle.bgcolor("color"), you create a background of the color. You can also create an image background by using turtle.bgpic("img.png"). The img.png is just an example. GIF's do not work. You could have

# Importing Turtle Again
import turtle
# Using bgcolor

To reset all the drawings, use turtle.reset(). The background will still be the same, though.


This also does not work for Python(with Turtle)

For a text input, use turtle.textinput("title", "question"). For a number input, use turtle.numinput(). By using minval and maxval, you create a minimum value for the number and a maximum value for the number. For example, you could have:

# Importing Turtle Again
import turtle
# Making An input
turtle.numinput("Number", "Type a number from 1 to 10:", minval=1, maxval=10)


If you want to exit very quick, use turtle.bye(). If you want to exit onclick, do turtle.exitonclick(). For example, you can have:

# Importing Turtle Again
import turtle
# Exiting onclick

More Window Methods

Setup Size

This does not work in Python(with Turtle)

You can change the setup by using turtle.setup(). There are 4 attributes: width, height, startx, and starty. The width and height are self-explanatory. Using startx will make the starting position align more to the left. The starty attribute does the opposite. You might have:

# Importing Turtle Again
import turtle
# Using Setup
turtle.setup(width=500, height=300, startx=0, starty=0)


This also does not work in Python(with Turtle)

I already talked about title in the very beginning. The syntax is turtle.title("title"). For example, you can have:

# Importing Turtle As Usual
import turtle
# Using title


This took me and my friend @SamiOsman 4 days to write! I hope you found this useful. If you did, make sure to upvote. Anyways, I'm done!


P.S If I have any grammar mistakes, please tell me so I can fix them. Also, make sure to check out @SamiOsman 's post: https://replit.com/talk/learn/Pyhton-Turtle-Tutorial/138758
ahmedo123454 (16)

this is what it is like bruhhhhhhhhhhh

JWZ6 (710)

@byronordolol um ok this is not a rickroll

JWZ6 (710)

it's quite obvious it's not a rickroll lol @byronordolol

byronordolol (4)

@JWZ6 literally oneperson recognizes the comedy of the 'ok boomer' how do i do strikethrough

JWZ6 (710)

@byronordolol lol use ~~ to start and end text in strikethrough

byronordolol (4)

@JWZ6 im gonna test strikthru since am new lol ~xD~

byronordolol (4)

@JWZ6 thanks lol me when week 7 in fnf

byronordolol (4)

@JWZ6 when human go bonk: D:

byronordolol (4)

@JWZ6 beeep boop bap bep bop

JWZ6 (710)

@byronordolol boyfriend goes brrrrrrr

byronordolol (4)

@JWZ6 me when zZHXYASuhdweiusgudghi7slgweuyuguhs67wrfsrewdsdssadswdsdwsdawsasdsawdadcaswdasdadswsrtfryttegystrtokenuhuegfgesugeugsugsygyqgswdsdQ

byronordolol (4)

@JWZ6 basicall my only online friend lol what seems to be odd is that nobody expects replit to be a place where u can chat with people lol

byronordolol (4)

@JWZ6 plus i got school and assignments to complete

fel1x0u (2)

This is cool. But I would recommend also teaching turtle.tracer() alongside turtle.speed.

JWZ6 (710)

@fel1x0u hmmm, I might do a part 2, though not sure

codermaster8 (7)

👎 Not working

This is not working I’m doing it but it does not work I can’t make it draw

JWZ6 (710)

@codermaster8 you must first import turtle

JWZ6 (710)

@codermaster8 which part doesn't work?

JWZ6 (710)

@codermaster8 like turtle.forward or something

JWZ6 (710)

@codermaster8 this has to be python or python(with Turtle)

codermaster8 (7)

yeah it says there is an error so what should I do @JWZ6

JWZ6 (710)

@codermaster8 well, try ctrl + c, ctrl + v some of my codeblocks i guess

JWZ6 (710)

@codermaster8 which error r ya getting

codermaster8 (7)

nevermind i got it to work maybe cause on my tablet it does not work @JWZ6

JWZ6 (710)

@codermaster8 hmm could be anyways yay! glad it works

codermaster8 (7)

I never knew but python (with turtle) doesn’t work but just regular python turtle works on my tablet @JWZ6

codermaster8 (7)

Oh now it doesn’t work lol @JWZ6

codermaster8 (7)

Lol i dont know why but now it’s working it’s like changing @JWZ6

codermaster8 (7)

This is my double square

Hope ya like it @JWZ6

Th3Coder (134)


I prefer using HTML, CSS, and JS instead of Turtle though
Th3Coder (134)

@JWZ6 to be honest, this is literally the fastest I've seen a post go trending, congrats!

JWZ6 (710)

@Th3Coder this went to trending in less than a minute LOL

Th3Coder (134)

@JWZ6 you deserve a place in The Guinness Book of World Records!

ch1ck3n (2295)

@ch1ck3n wow fastest reply ever

JWZ6 (710)

@ch1ck3n just got ya 1,700 cycles

JWZ6 (710)

@ch1ck3n glad u like me tutorial also yay too

ch1ck3n (2295)

@JWZ6 ya just got rick rolled

JWZ6 (710)

@ch1ck3n lol x-d out before it could

Th3Coder (134)

@ch1ck3n thank you for blessing me with this link

ch1ck3n (2295)

@JWZ6 @Th3Coder give me a coding challenge for a website

JWZ6 (710)

@ch1ck3n also y am i gettin 10 notifs every 2 min?

Th3Coder (134)

@ch1ck3n easy, hard, or impossible?

ch1ck3n (2295)

@JWZ6 this post is this morning's #general for us

ch1ck3n (2295)



JWZ6 (710)

@ch1ck3n it 1705 dat also neat

ch1ck3n (2295)

@JWZ6 frick why do these people keep upvoting me

ch1ck3n (2295)


officially the smartest and best AI everrr

JWZ6 (710)

@ch1ck3n OF COURSE shoutout to @CatR3kd for making it! (sorry for the ping)

Th3Coder (134)


Make a good website without using StackOverFlow.

Difficulty: IMPOSSIBLE

Okay for real though...

Make an equation solver website, using DOGESCRIPT.

Th3Coder (134)

@ch1ck3n wait you're really making it-

ch1ck3n (2295)

@Th3Coder im making the stack overflow one

CatR3kd (568)

huh what did I make lmao @JWZ6