import turtle
turtle.setup(width=950, height=300)
t = turtle.Turtle()
t.shape('turtle')
polygons = [(-400, 0, "red"), (-300, 3, "orange"), (-200, 4, "yellow"), (-100, 5, "green"),
(0, 6, "blue"), (100, 7, "purple"), (200, 8, "orange"), (300, 9, "green")]
for polygon in polygons:
t.penup()
t.goto(polygon[0], -50)
t.color(polygon[2])
t.pendown()
if polygon[1] == 0:
t.circle(50)
else:
t.circle(50, steps=polygon[1])
turtle.exitonclick()
import turtle: The turtle will be imported into the code
turtle.setup(width=950, height=300): The area and how large the turtle will be.
t = turtle.Turtle(): The turtle will be called t.
t.shape('turtle'): The shape of the turtle will be a turtle.
polygons = [(-400, 0, "red"), (-300, 3, "orange"), (-200, 4, "yellow"), (-100, 5, "green"),
(0, 6, "blue"), (100, 7, "purple"), (200, 8, "orange"), (300, 9, "green")]
: The polygons will be these coordinates and the colors of the lines will be these.
for polygon in polygons:
t.penup(): The pen will stop drawing.
t.goto(polygon[0], -50): It will go to the right x coodinates and y coordinates to -50.
t.color(polygon[2]) : The color of the polygon will be chosen.
t.pendown(): The pen will move down and ready to draw.
if polygon[1] == 0:
t.circle(50): If polygon[1] is 0, then it means circle so that it will draw a circle with radius 50.
else:
t.circle(50, steps=polygon[1]): Else, divide the shape in the equal number of given steps.
turtle.exitonclick(): It will be exited on click.