-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathturtlestar.py
More file actions
36 lines (36 loc) · 776 Bytes
/
turtlestar.py
File metadata and controls
36 lines (36 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import turtle
def koch(size,n):
if n==0:
turtle.fd(size)
else:
for angle in[0,80,-160,80]:
turtle.left(angle)
koch(size/3,n-1)
def main():
turtle.speed(0)
turtle.setup(1000,800)
turtle.penup()
turtle.goto(-200,100)
turtle.pendown()
turtle.pensize(2)
turtle.pencolor("red")
leval=3
koch(300,leval)
turtle.right(60)
turtle.pencolor("green")
koch(300,leval)
turtle.right(60)
turtle.pencolor("blue")
koch(300,leval)
turtle.right(60)
turtle.pencolor("red")
koch(300,leval)
turtle.right(60)
turtle.pencolor("green")
koch(300,leval)
turtle.right(60)
turtle.pencolor("blue")
koch(300,leval)
turtle.hideturtle()
turtle.done()
main()