Hey,
I am trying to draw a series of fibonacci squares using turtles.
I am new to python but am using loops to try to draw them.
This is what I have so far...
Can anyone help?!?
I have added some other code but it still is not increasing the size of each square as it goes on...
import turtle
wn = turtle.Screen()
wn.bgcolor("lightgreen")
tess = turtle.Turtle()
tess.color("blue")
squares = input("How many squares do you want?")
def recur_fibo(n):
if n <= 1:
return n
else:
return(recur_fibo(n-1) + recur_fibo(n-2))
n = 10
for sqs in range(int(squares)):
for i in range(6):
tess.forward(recur_fibo(n))
tess.left(90)
tess.right(90)
wn.mainloop()
I am trying to draw a series of fibonacci squares using turtles.
I am new to python but am using loops to try to draw them.
This is what I have so far...
import turtle wn = turtle.Screen() wn.bgcolor("lightgreen") tess = turtle.Turtle() tess.color("blue") squares = input("How many squares do you want?") n = 10 for sqs in range(int(squares)): for i in range(6): #it has 6 turns (not 4) because the next square begins from the corner diagonal to the corner the preceding square began tess.forward(n) tess.left(90) tess.right(90) #this points the turtle in the right direction to start the next square! wn.mainloop()I can code the fibonacci sequence to get integer terms but am stuck on how to nest this within my loop so that each square is drawn with side lengths in accordance with the fibonacci sequence.
Can anyone help?!?
I have added some other code but it still is not increasing the size of each square as it goes on...
import turtle
wn = turtle.Screen()
wn.bgcolor("lightgreen")
tess = turtle.Turtle()
tess.color("blue")
squares = input("How many squares do you want?")
def recur_fibo(n):
if n <= 1:
return n
else:
return(recur_fibo(n-1) + recur_fibo(n-2))
n = 10
for sqs in range(int(squares)):
for i in range(6):
tess.forward(recur_fibo(n))
tess.left(90)
tess.right(90)
wn.mainloop()