Draw A Star In Python Turtle
Published October 10, 2023 by Jarvis Silva
In this tutorial I will show you how to draw a star in python turtle module so if you are intrested in creating this program follow till the end.
To draw star using python we will use the turtle module, it allows us to draw graphics, animations drawing etc. so make sure you have turtle module installed, to install use below command:
pip install turtle
After installing the turtle module, open a code editor and create a python file now let’s code in it.
Python code to draw a star
#import turtle
import turtle
# set screen
Screen = turtle.Turtle()
turtle.pensize(4)
# Draw star pattern
turtle.penup()
turtle.setpos(-90,30)
turtle.pendown()
for i in range(5):
turtle.pencolor("blue")
turtle.forward(200)
turtle.right(144)
turtle.penup()
turtle.setpos(80,-140)
turtle.pendown()
# choose pen color
turtle.pencolor("Black")
turtle.done()
Above is the complete python code for drawing a star, as you can see we have used turtle functions and methods to create this entire program, so now copy the code and paste it in your file and run the program, below is the output you will get.
Also Draw Olympic Rings In Python.
As you can see we successfully created a python program to draw a star using turtle module, I hope you found this tutorial helpful and useful, do share it with python developers who might find it useful. Thank you for reading, Have a nice day 😊