loading...

Draw a Fibonacci Curve with Python Turtle

0xbf profile image Bo ・1 min read

Just for fun:

from turtle import Turtle
from random import randint

t = Turtle()
scale = 5

def fib(n):
    if n == 0:
        return 0
    if n == 1:
        return 1
    return fib(n-1) + fib(n-2)

def semi_circle(radius):
    rgb = [randint(0, 255) for i in range(3)]
    t.color(*rgb)
    t.circle(radius, 90)

for i in range(10):    
    semi_circle(fib(i) * scale)

Result:

fibonacci curve

Discussion

markdown guide