Skip to content

Instantly share code, notes, and snippets.

@umcconnell
Created August 3, 2020 11:55
Show Gist options
  • Save umcconnell/93f865c8d3a1702a79f1629ff30d9a52 to your computer and use it in GitHub Desktop.
Save umcconnell/93f865c8d3a1702a79f1629ff30d9a52 to your computer and use it in GitHub Desktop.
Draw the fibonacci spiral with Python turtle
import argparse
import turtle
parser = argparse.ArgumentParser(description='Draw the fibonacci spiral')
parser.add_argument('n', type=int, help='Length of fibonacci sequence')
parser.add_argument('-s', '--scale', type=int, default=1)
parser.add_argument('--speed', type=int, default=6, help='Turtle speed')
args = parser.parse_args()
def fib(n):
a, b = 1, 1
for _ in range(n):
yield a
a, b = b, a+b
turtle.speed(args.speed)
turtle.right(90)
for n in fib(args.n):
turtle.circle(n*args.scale, 90)
@umcconnell
Copy link
Author

The code does not work. Please provide further detailed guidelines. Thanks.

Can you please give more details on what is not working and what environment you're using? Any kind of error message might be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment