Search code examples
pythonturtle-graphicspython-turtle

How can i draw a nice spiral in python with turtle?


I have a homework to draw a spiral(from inside to outside) in python with turtle, but I cant think of a way to do that, beside what I did its need to be like this:

enter image description here

I tried to do it like that, but its not working properly.

import turtle

turtle.shape ('turtle')


d = 20  #Distance

a = 1   #StartingAngle
x = 200    #Num of loops 

for i in range (x):
turtle.left(a)
turtle.forward(d)
a = a + 5

Solution

  • You are increasing the wrong variable in your loop.

    A spiral is like a "circunference whose radius increases over time".

    You should increase the d variable over time, and not the angle a. The amount of the increase of each loop will be essential to determine the appearance of your spiral, but you can obtain a good value for the increase with some calculation or by trial and error.