Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python turtle sierpinski triangle

from turtle import *

speed(0) # set penspeed
left(90) # start position

def triangle(size, order):
    if order == 0:
        return
    for i in range(3):
        forward(size)
        triangle(size/2, order - 1) # recursive function
        backward(size)
        left(120)
 
triangle(100, 5) # test sierpinski triangle

done()
 
PREVIOUS NEXT
Tagged: #python #turtle #sierpinski #triangle
ADD COMMENT
Topic
Name
8+5 =