Turtle Programming in Python

Last Updated : 15 Jan, 2026

Turtle is a Python module that provides a virtual drawing board where one can control a cursor (called a turtle) to draw shapes and patterns on the screen using simple commands.

  1. Control Movement: Move the turtle to exact positions and rotate it in any direction.
  2. Interactive: The drawing can respond to mouse clicks or keyboard input.
  3. Set Speed: One can make the turtle draw faster or slower to see the drawing step by step.
  4. Change Pen Style: You can change the color and thickness of the pen and fill shapes with colors.
  5. Draw Shapes and Stamps: You can draw shapes or leave a turtle-shaped stamp on the screen.

Plotting Using Turtle

To use Turtle in Python, simply import turtle (no installation needed). A basic Turtle program follows four steps:

1. Import the turtle module: import Turtle in Python in the following ways.

import turtle

or

from turtle import *

2. Create a turtle to control: After importing the turtle library, we create a drawing window and a turtle. Here, 'wn' is the window and 'skk' is the turtle.

wn = turtle.Screen()
wn.bgcolor("light green")
wn.title("Turtle")
skk = turtle.Turtle()

3. Draw around using the turtle methods: Now that the window and turtle are ready, we can move the turtle. For example, to move skk forward by 100 pixels.

skk.forward(100)

4. Run turtle.done(): This draws a line 100 pixels long in the direction 'skk' is facing. To finish the program, call.

turtle.done()

Examples

Below are some examples of Turtle programs demonstrating different shapes and patterns.

Shape 1: Square

In this program, we show how to draw a square using Turtle in Python.

Python
import turtle 
skk = turtle.Turtle()

for i in range(4):
    skk.forward(50)
    skk.right(90)
    
turtle.done()

Output

Explanation:

  • skk = turtle.Turtle(): Create a turtle named skk.
  • skk.forward(50): Move forward 50 units.
  • skk.right(90): Turn 90° clockwise.
  • turtle.done(): Keep the window open.

Shape 2: Star

In this program, we show how to draw a star using Turtle in Python.

Python
import turtle
star = turtle.Turtle()

star.right(75)
star.forward(100)

for i in range(4):
    star.right(144)
    star.forward(100)
    
turtle.done()

Output

Some Turtle Programs

1. Spiral Square Outside In and Inside Out

In this program, we draw spiral squares that grow outward and inward to create a visually interesting pattern.

Python
import turtle 
wn = turtle.Screen()
wn.bgcolor("light green")
skk = turtle.Turtle()
skk.color("blue")

def sqrfunc(size):
    for i in range(4):
        skk.fd(size)
        skk.left(90)
        size = size + 5

sqrfunc(6)
sqrfunc(26)
sqrfunc(46)
sqrfunc(66)
sqrfunc(86)
sqrfunc(106)
sqrfunc(126)
sqrfunc(146)

Output