Table of contents
1.
Introduction
2.
Steps to Draw a Star Using Turtle in Python
2.1.
Approach 1 - Creating Simple Star
2.2.
Code
2.2.1.
Output
2.3.
Approach 2 - Creating a Colorful Star
2.4.
Code
2.4.1.
Output
3.
Frequently Asked Questions
4.
Conclusion
Last Updated: Mar 20, 2025
Easy

How to Make a Star in Python Turtle

Introduction

A turtle is a Python tool that functions similarly to a drawing board, allowing us to tell a turtle to draw all over it! Many turtle functions can be used to move the turtle around. The turtle explores the turtle library.

The turtle library in Python may be used to create different forms on a canvas. The programmer can direct a pen in a particular direction by specifying its heading and distance. In this article, we'll look at using the Turtle module to create Star. Steps to draw a Polygon turtle.

Steps to Draw a Star Using Turtle in Python

Approach 1 - Creating Simple Star

 

For creating a simple star:

  • Import a turtle and create an object from it.
     
  • Get a screen board for the turtle to sketch on.
     
  • Iterate the loop five times if you need five edges in the star.
     
  • Move forward turtle x length and turn it 144 degrees; it depends on you.
     
  • It will give you the output of a perfect star.

Code

# draw any polygon in turtle
# import turtle
import turtle
 
# Screen board for the turtle to sketch on.
screenForSketching = turtle.Screen()
 
# creating turtle object
ob = turtle.Turtle()
 
# Iterate the loop five times for a star
for i in range(5):
 
        # moving turtle 100 units forward
        ob.forward(100)
 
        # rotating turtle 144 degree right
        ob.right(144)
You can also try this code with Online Python Compiler
Run Code


Output

Approach 2 - Creating a Colorful Star

 

For creating a colorful star:

  • Import a turtle and create an object from it.
     
  • Get a screen board for the turtle to sketch on.
     
  • Select the color of the turtle.
     
  • Iterate the loop five times if you need five edges in the Star.
     
  • Move forward turtle x length and turn it 144 degrees. It depends on you.
     
  • It will give you a perfect Star.
     
  • Now fill in the color in the Star.

Code

# draw any polygon in turtle
# import turtle
import turtle
 
# function to draw
# colored Star
def create_color_star():
    
    # size of Star
    sigeOfStar = 100
    
    # Assign colour to the edges.
    turtle.color("orange")
    
    # Set the width
    turtle.width(4)
    
    # Give angle to form Star
    assine_angle = 120
    
    # Fill the colour as of your choice.
    turtle.fillcolor("green")
    turtle.begin_fill()
    
    # Create a Star
    for side in range(5):
        turtle.forward(sigeOfStar)
        turtle.right(angle)
        turtle.forward(sigeOfStar)
        turtle.right(72 - angle)
        
    # fill color
    turtle.end_fill()
 
# Driver code
create_color_star()
You can also try this code with Online Python Compiler
Run Code

Output

You can compile it with online python compiler.

Frequently Asked Questions

  1. Is Turtle a better alternative than Tkinter?
    Turtle is primarily used for UI (Buttons, Widgets, and Text) Tkinter is primarily used for GUI (Buttons, Widgets, and Text) (Animations and Games). The turtle was also created as a simple way for children to code.
     
  2. What does a turtle represent?
    The turtle is both the name of the onscreen pen that you use to draw with and the library's name. In brief, the Python turtle library is a fun and engaging approach for new programmers to develop a feel for Python programming. Turtle is mostly used to introduce children to computer technology.
     
  3. Is it possible to combine Turtle and Tkinter?
    Yes. Python turtle has two modes of operation: standalone and embedded into a bigger Tkinter program. When utilizing turtle embedded, you work with RawTurtle, TurtleScreen, and optionally ScrolledCanvas instead of Turtle and Screen. As desired, you create your Tkinter interface containing your turtle graphics on a Canvas.
     
  4. In Python, how can you move a turtle without drawing?
    Toggle drawing on and off with up and down, or move without drawing with the “setx”, “sety”, or “goto” functions.
     
  5. What are all the different sorts of Python libraries?
    Thanks to its over 137,000 libraries, Python can be used to construct applications and models in a range of domains, including machine learning, data science, data visualization, image and data processing, and many others.

Conclusion

In this article, we draw different types of stars.  You must have mastered the art of drawing and coloring a star by now. We hope that this blog will help you understand the concept of the turtle library and one of the applications, i.e., to draw the different types of shapes; if you like to learn more about it, check out our other blogs, Python libraries.

Recommended Readings:

Live masterclass