File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change 6
6
# function to create koch snowflake or koch curve
7
7
def snowflake (lengthSide , levels ):
8
8
if levels == 0 :
9
- forward (lengthSide )
9
+ t . forward (lengthSide )
10
10
return
11
11
lengthSide /= 3.0
12
12
snowflake (lengthSide , levels - 1 )
13
- left (60 )
13
+ t . left (60 )
14
14
snowflake (lengthSide , levels - 1 )
15
- right (120 )
15
+ t . right (120 )
16
16
snowflake (lengthSide , levels - 1 )
17
- left (60 )
17
+ t . left (60 )
18
18
snowflake (lengthSide , levels - 1 )
19
19
20
20
21
21
# main function
22
22
if __name__ == "__main__" :
23
- speed (0 ) # defining the speed of the turtle
23
+ t = turtle .Pen ()
24
+ t .speed (0 ) # defining the speed of the turtle
24
25
length = 300.0 #
25
- penup () # Pull the pen up – no drawing when moving.
26
+ t . penup () # Pull the pen up – no drawing when moving.
26
27
# Move the turtle backward by distance, opposite to the direction the turtle is headed.
27
28
# Do not change the turtle’s heading.
28
- backward (length / 2.0 )
29
- pendown ()
29
+ t . backward (length / 2.0 )
30
+ t . pendown ()
30
31
for i in range (3 ):
31
32
# Pull the pen down – drawing when moving.
32
33
snowflake (length , 4 )
33
- right (120 )
34
+ t . right (120 )
34
35
# To control the closing windows of the turtle
35
- mainloop ()
36
+ #mainloop()
37
+
You can’t perform that action at this time.
0 commit comments