Question: Write a Python program that will produce our simplified spirograph images from squares. Your program should include a function: spiro(num, side) that takes two arguments:
Write a Python program that will produce our simplified "spirograph" images from squares. Your program should include a function: spiro(num, side) that takes two arguments: the number of squares to draw in one revolution, and the side length of each square in the figure. Remember: there are 360 degrees in a circle.
Here is a function that demonstrates how to draw a randomly colored filled square. Youll want to copy-paste this function into your program, and call this function from within a loop in your spirograph function, so that it draws multiple squares:
import turtle, random
turtle.speed(0)
turtle.delay(0)
def filled_square(side):
r = random.random()
g = random.random()
b = random.random()
turtle.color(r,g,b)
turtle.begin_fill()
for i in range(4):
turtle.forward(side)
turtle.left(90)
turtle.end_fill()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
