Code:
Explanation:
1. Import Libraries
import turtleimport time
- turtle draws the flower design.
- time adds pauses to the animation.
2. Create the Screen
s = turtle.Screen()s.setup(750, 750)s.bgcolor("#100719")s.title("Spirograph Flower")s.tracer(1)
- Creates a 750 × 750 window.
- Sets a dark purple background.
- Adds the title “Spirograph Flower”.
- Enables screen updates during drawing.
3. Configure the Turtle
t = turtle.Turtle()t.hideturtle()t.speed(0)t.pensize(2)
- Creates the drawing turtle.
- Hides the cursor.
- Sets the fastest drawing speed.
- Sets the line thickness to 2.
4. Define Neon Colors
colors = ["#FF4D9D", "#A855F7", "#00E5FF", "#FFD166"]
Defines four colors: pink, purple, cyan, and golden yellow.
5. Create Three Flower Layers
for layer in range(3): radius = 100 + layer * 35
- Creates three layers of petals.
- Increases the radius for each layer: 100, 135, and 170.
6. Set Petal Positions
for i in range(24): t.penup() t.goto(0, 0) t.setheading(i * 15 + layer * 5) t.pendown()
- Draws 24 curved patterns per layer.
- Moves the turtle to the center.
- Rotates each pattern by 15° plus a small layer offset.
- Puts the pen down to start drawing.
7. Draw Curved Petals
t.pencolor(colors[(i + layer) % 4])t.circle(radius, 70)t.left(110)t.circle(radius, 70)
- Changes colors for a multicolored effect.
- Draws a 70° curved arc.
- Turns left by 110°.
- Draws another arc to form a petal-like shape.
8. Animate the Flower
s.update()time.sleep(0.035)
- Refreshes the screen.
- Adds a short pause so the drawing animation is visible.
9. Draw the Center
t.penup()t.goto(0, -18)t.pendown()t.pencolor("#FFD166")t.fillcolor("#FF4D9D")t.begin_fill()t.circle(18)t.end_fill()
- Moves to the center area.
- Sets a golden outline and pink fill.
- Draws a filled circle of radius 18.
10. Add Decorative Outer Dots
for i in range(36): t.penup() t.goto(0, 0) t.setheading(i * 10) t.forward(245) t.dot(5, colors[i % 4])
- Creates 36 decorative dots.
- Rotates by 10° for each dot.
- Moves 245 units from the center.
- Uses different neon colors for the dots.
11. Finish the Program
turtle.done()
Keeps the graphics window open after the drawing finishes.



