Python Turtle Commands

In this Python tutorial, we will discuss Python turtle commands and, we will see the syntax used for Python turtle. Also, we will see the below topics:

Python Turtle Commands

Here is the list of turtle commands in Python.

Here’s a list of some common Python Turtle command names and a short description:

Command NameDescription
turtle.forward(distance)Moves the turtle forward by the specified distance.
turtle.backward(distance)Moves the turtle backward by the specified distance.
turtle.right(angle)Turns the turtle to the right by the specified angle.
turtle.left(angle)Turns the turtle to the left by the specified angle.
turtle.penup()Lifts the pen, so that the turtle doesn’t draw.
turtle.pendown()Puts the pen down, so that the turtle can draw.
turtle.pensize(width)Sets the width of the pen.
turtle.pencolor(color)Sets the pen color. Color can be a string or RGB.
turtle.goto(x, y)Moves the turtle to an absolute position (x, y).
turtle.setheading(angle)Sets the turtle’s heading to an absolute angle.
turtle.speed(speed)Sets the speed of the turtle. 1 slowest, 10 fastest.
turtle.circle(radius)Draws a circle with the given radius.
turtle.dot(size, color)Draws a dot with the given size and color.
turtle.clear()Clears the screen, but doesn’t move the turtle.
turtle.reset()Clears the screen and resets turtle to starting pos.
turtle.undo()Undoes the last turtle action.
turtle.begin_fill()Begins filling a shape drawn by the turtle.
turtle.end_fill()Ends filling a shape, closing and filling it.
turtle.fillcolor(color)Sets the fill color. Color can be a string or RGB.
turtle.stamp()Stamps the turtle shape onto the canvas.
turtle.hideturtle()Hides the turtle.
turtle.showturtle()Shows the turtle.
turtle.isvisible()Returns True if the turtle is visible.
turtle.write(text)Writes the text at the turtle’s current position.
Python Turtle Commands
Python Turtle Commands

Here check out a few useful Python turtle command and examples.

shape() command

The turtle shape() command is used to set the turtle shape with a given name, if the shape is not given then it returns the default shape. Here, the name will be the string parameters like triangle, square, circle, arrow, and classic.

Syntax:

turtle.shape(name)

up() command

The turtle up() command stops all drawing. It pull the pen up and nothing will be drawn to the screen, until down is called.

Syntax:

turtle.up()

Read Python Turtle Write Function

down() command

The turtle down() command is used to pull back the pen down on the screen and it starts drawing when moving.

Syntax:

turtle.down()

Example:

import turtle
turtle.forward(40)
turtle.up()
turtle.forward(40)
turtle.down()
turtle.forward(30)
turtle.done()

You may like Python Pandas CSV Tutorial.

backward() command

The turtle backward() command is used to move the turtle backward by a specified distance, which is opposite to the direction of the turtle head.

Syntax:

turtle.backward(distance)

forward() command

The turtle forward() command is used to move the turtle forward by the specified distance, in the direction the turtle headed.

Syntax:

turtle.forward(distance)

color() command

The turtle color() command is used to change the color of the turtle, and the default color of the turtle is “black”.

Syntax:

turtle.color(*args)

Example:

import turtle
turtle.forward(40)
turtle.color("orange")
turtle.forward(60)
turtle.done()

position() command

The turtle position() command is used to return the turtle current position (x,y).

Syntax:

turtle.position()

goto() command

The python turtle goto() command is used to move the turtle from the current position to the x,y location along the shortest linear path between the two locations.

Syntax:

turtle.goto(x,y)

left() command

The turtle left() command is used to change the direction of the turtle by the given value of the argument. So, it turns the turtle counterclockwise

Syntax:

turtle.left(angle)

Example:

import turtle
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.done()

right() command

The Python turtle right() command is used to change the direction of the turtle by the given value of the argument. So, it turns the turtle clockwise.

Syntax:

turtle.right(angle)

Example:

import turtle
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.done()

begin_fill() command

In Python, the turtle begin_fill() command is used to call just before drawing a shape to be filled. It does not take any argument.

Syntax:

turtle.begin_fill() 

end_fill() command

The turtle end_fill() command is used to fill the shape drawn after the last call to begin_fill(). It does not take any argument

Syntax:

turtle.end_fill()

fillcolor() command

The turtle fillcolor() command is used to return or set the fillcolor. If the turtle shape is polygon then we can set the interior color with the newly set fillcolor.

Syntax:

turtle.fillcolor(*args)

Python turtle window_width() commands

The turtle window_width() command is used to return the width of the current window in pixels. It does not require any argument.

Syntax:

turtle.window_width()

dot() command

The turtle dot() command is used to draw a circular dot with a particular size in the current position, with some color. We can set the size and color.

Syntax:

turtle.dot(size, *color)

Example:

import turtle
turtle.forward(120)
turtle.dot(30, "red")
turtle.done()

You may like the following Python tutorials:

In this tutorial, we have learned about Python turtle commands with the syntax and examples.