Rename ex5.py to sierpinski.py

This commit is contained in:
Daniel
2022-11-03 11:41:18 +02:00
committed by GitHub
parent 3f77101292
commit a623a823a6

27
LabMD_1/sierpinski.py Normal file
View File

@@ -0,0 +1,27 @@
import turtle
def draw(length, depth):
if depth == 0:
for i in range(0, 3):
t.fd(length)
t.left(120)
else:
draw(length/2, depth-1)
t.fd(length/2)
draw(length/2, depth-1)
t.bk(length/2)
t.left(60)
t.fd(length/2)
t.right(60)
draw(length/2, depth-1)
t.left(60)
t.bk(length/2)
t.right(60)
window = turtle.Screen()
t = turtle.Turtle()
t.speed(0)
draw(400, 4)
window.exitonclick()