Created
December 29, 2021 22:34
-
-
Save CodeMaster7000/fb736bbe7f3f9b8ee99aa58226f75884 to your computer and use it in GitHub Desktop.
A Fibonacci Spiral coded in Python 3 with Turtle.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from turtle import * | |
| fibo_nr = [1,1,2,3, 5, 8, 13, 21, 34,55] | |
| def draw_square(side_length): | |
| for i in range(4): | |
| forward(side_length) | |
| right(90) | |
| nr_squares=len(fibo_nr) | |
| factor = 3 | |
| penup() | |
| goto(50,50) | |
| pendown() | |
| for i in range(nr_squares): | |
| draw_square(factor*fibo_nr[i]) | |
| penup() | |
| forward(factor*fibo_nr[i]) | |
| right(90) | |
| forward(factor*fibo_nr[i]) | |
| pendown() | |
| penup() | |
| goto(50,50) | |
| setheading(0) | |
| pensize(4) | |
| pendown() | |
| for i in range(nr_squares): | |
| circle(-factor*fibo_nr[i],90) | |
| hideturtle() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment