Hi everyone. I’m ISHITA SINGH. Today I’d like to tell you about how to make a spirograph from python.
Now let’s get started.
First, we should know about the python language.
WHAT DO YOU MEAN BY PYTHON LANGUAGE?
Python is a straightforward language and easy to learn in comparison to other languages. It is high level, OOP(object-oriented programming language ), interpreted general-purpose language. It is mostly used in artificial intelligence, web development, machine learning, or making high or small-level video games and is used in many more applications.
WHAT IS A SPIROGRAPH IN PYTHON?
A spirograph is a lovely geometrical shape in the sign, which is often balanced in the form of both tree cutting tools.ks It produces mathematical roulette curves of the range in fact experienced as hypotrochoids and epitrochoids .
We can also make many different and interesting patterns with more colors.
HOW TO MAKE A SPIROGRAPH USING PYTHON LANGUAGE?
Below is the application or execution.
Spirograph
The output should look like this:

To make this beautiful spirograph, We'll also provide the source code. The only thing you need to do is to copy and paste the source code into your python IDLE shell.
Source code-
import turtle
turtle.bgcolor("black")
turtle.pensize(2)
turtle.speed(0)
for i in range(6):
for colours in ["red", "magenta", "blue", "cyan", "green", "yellow", "white" ]:
turtle.color(colours)
turtle.circle(100)
turtle.left(10)
turtle.hideturtle()
You can make many other designs or patterns of spirographs. One example is given below.
Spirograph(Hypotrochoid)
Output should look this this:

Source code-
import turtle
from math import cos,sin
from time import sleep
window = turtle.Screen()
window.bgcolor("#FFFFFF")
mySpirograph = turtle.Turtle()
mySpirograph.hideturtle()
mySpirograph.tracer(0)
mySpirograph.speed(0)
mySpirograph.pensize(2)
myPen = turtle.Turtle()
myPen.hideturtle()
myPen.tracer(0)
myPen.speed(0)
myPen.pensize(3)
myPen.color("#AA00AA")
R = 125
r = 75
d = 125
angle = 0
myPen.penup()
myPen.goto(R-r+d,0)
myPen.pendown()
theta = 0.2
steps = int(6*3.14/theta)
for t in range(0,steps):
mySpirograph.clear()
mySpirograph.penup()
mySpirograph.setheading(0)
mySpirograph.goto(0,-R)
mySpirograph.color("#999999")
mySpirograph.pendown()
mySpirograph.circle(R)
angle+=theta
x = (R - r) * cos(angle)
y = (R - r) * sin(angle)
mySpirograph.penup()
mySpirograph.goto(x,y-r)
mySpirograph.color("#222222")
mySpirograph.pendown()
mySpirograph.circle(r)
mySpirograph.penup()
mySpirograph.goto(x,y)
mySpirograph.dot(5)
x = (R - r) * cos(angle) + d * cos(((R-r)/r)*angle)
y = (R - r) * sin(angle) - d * sin(((R-r)/r)*angle)
mySpirograph.pendown()
mySpirograph.goto(x,y)
mySpirograph.dot(5)
myPen.goto(mySpirograph.pos())
mySpirograph.getscreen().update()
sleep(0.05)
sleep(0.5)
mySpirograph.clear()
mySpirograph.getscreen().update()
HOW TO INCREASE THE SPEED OF THE TURTLE?
for increasing the speed of the turtle, you need to set the turtle speed
- fastest' : 0.
- fast' : 10.
- 'normal' : 6.
HOW TO INSTALL PYTHON IDLE ON YOUR WINDOWS, MAC, LINUX ETC?
1. open your browser and search python download or click on the below link.
https://www.python.org/downloads/
2. Then click on the latest version of python.
3. Then a page gets open, scroll down the page, and click on a suitable version from the files section.
4. After this downloading, get started.
HOW TO RUN A PROGRAM IN PYTHON IDLE?
1. First, open your idle shell and type your code in it.
2. After that, save your code.
3. Then, from the menu bar, click on the run module.
You can also use many other software applications for running python codes, forex. ANACONDA, VISUAL STUDIO CODE, INTELIIJ IDEA, etc.
If you are reading my article, thank you so much
yours truly
Ishita Singh
You must be logged in to post a comment.