Python Turtle Code: Rotating Trapezoid

Опубликовано: 21 Март 2026
на канале: Basic Python Turtle Art
210
2

A spirograph created by 15 trapezoids stamped as images of a rotating figure. The Python Turtle code uses a loop. The "normal" orientation of the turtle in this case is facing the first side of the last trapezoid drawn.

Please feel free to copy and paste the following code. Ask questions if you have any, and subscribe. Enjoy!!
import turtle
scrin = turtle.Screen()
scrin.bgcolor("light green")
t = turtle.Turtle()
t.pensize(5)
t.speed(3)
for i in range(15): #draw 15 trapezoids, 24 degrees apart
t.color("blue")
t.forward(250)
t.left(120)
t.color("black")
t.forward(100)
t.left(60)
t.color("red")
t.forward(150)
t.left(60)
t.color("blue")
t.forward(100)
t.left(144) #new_trapezoid: rotate turtle 120 + 24 degrees
scrin.exitonclick()