Open In App

Draw Star Using Turtle Graphics-Python

Last Updated : 29 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Python's Turtle module offers a fun and interactive way to create graphics by controlling a turtle (pen) to draw on the screen. In this article, we will learn how to use Turtle to draw a simple star. Some commonly used methods are:

  • forward(length) moves the pen in the forward direction by x unit.
  • backward(length) moves the pen in the backward direction by x unit.
  • right(angle) rotate the pen in the clockwise direction by an angle x.
  • left(angle) rotate the pen in the anticlockwise direction by an angle x.
  • penup() stop drawing of the turtle pen.
  • pendown() start drawing of the turtle pen.

Steps to Draw a Star

Let’s go through these steps to implement this in Python:

  • First import turtle module in the idle or editor you are using.

import turtle

  • Get a screen board on which turtle will draw.

ws=turtle.Screen()

A screen like this will appear:-

  • Define an instance for turtle.
  • For a drawing, a Star executes a loop 5 times.
  • In every iteration move the turtle 100 units forward and move it right 144 degrees.
  • This will make up an angle 36 degrees inside a star.
  • 5 iterations will make up a Star perfectly.

Below is the python implementation of the above approach.

Python
import turtle

scr = turtle.Screen()
t = turtle.Turtle()

for i in range(5):
    t.forward(100) 
    t.right(144)    

Output

Output
Turtle making a star

Explanation:

  • turtle.Screen() creates the drawing window for the turtle.
  • t = turtle.Turtle() creates the turtle object, which will act as the pen for drawing.
  • For loop runs 5 times, with t.forward(100) moving the turtle 100 units forward and t.right(144) turning it by 144 degrees to draw the star's points.

Let’s draw a more colorful and styled version of the star using a color list and pen positioning.

Python
import turtle

scr = turtle.Screen()
clr = ['red', 'green', 'blue', 'yellow', 'purple']

turtle.pensize(4)
turtle.penup()
turtle.setpos(-90, 30)
turtle.pendown()
for i in range(5):
    turtle.pencolor(clr[i])
    turtle.forward(200)
    turtle.right(144)

turtle.penup()
turtle.setpos(80, -140)
turtle.pendown()
turtle.pencolor("black")

turtle.done()

Output

colourfullStar
Turtle making a star

Explanation:

  • Initializes the drawing window with turtle.Screen() and sets the pen size to 4. The pen is moved to position (-90, 30).
  • For loop runs 5 times, changing the pen color with turtle.pencolor(clr[i]) and drawing each point using turtle.forward(200) and turtle.right(144).
  • After the star, the pen moves to (80, -140) and changes color to black with turtle.pencolor("black").

Next Article
Practice Tags :

Similar Reads