Install turtle package using below command:
pip import turtle
Below is the code to generate a pentagon
#import turtle package
import turtle
import turtle
#list with colors is declared
color = ['blue','orange','purple','red','yellow']
#window created to draw a pentagon graphic
window = turtle.Screen()
#decide the screen
pentagon = turtle.Turtle()
#set the pensize
pentagon.pensize(25)
#draw 5 sides of pentagon using the for loop below
for line in range(5):
#setting the color by pulling eahj color from the list - color
pentagon.pencolor(color[line])
pentagon.forward(200)
pentagon.right(288)
turtle.done()
The output is as below:
0 Comments