import turtle, math def kochLeft(t,n,d): if n == 0: t.forward(d) else: kochLeft(t,n-1,d/3) t.left(60) kochLeft(t,n-1,d/3) t.right(120) kochLeft(t,n-1,d/3) t.left(60) kochLeft(t,n-1,d/3) def kochRight(t,n,d): if n == 0: t.forward(d) else: kochRight(t,n-1,d/3) t.right(60) kochRight(t,n-1,d/3) t.left(120) kochRight(t,n-1,d/3) t.right(60) kochRight(t,n-1,d/3) def kochtrLeft(t,n,d): kochLeft(t,n,d) t.left(120) kochLeft(t,n,d) t.left(120) kochLeft(t,n,d) t.left(120) def kochtrRight(t,n,d): kochRight(t,n,d) t.left(120) kochRight(t,n,d) t.left(120) kochRight(t,n,d) t.left(120) def kochsqLeft(t,n,d): kochLeft(t,n,d) t.left(90) kochLeft(t,n,d) t.left(90) kochLeft(t,n,d) t.left(90) kochLeft(t,n,d) t.left(90) def kochsqRight(t,n,d): kochRight(t,n,d) t.left(90) kochRight(t,n,d) t.left(90) kochRight(t,n,d) t.left(90) kochRight(t,n,d) t.left(90) def tornLeft(t,o,d): if o==0: t.forward(d) else: a = 86.67 dn = 0.47*d tornLeft(t,o-1,dn) t.left(a) tornLeft(t,o-1,dn) t.right(2*a) tornLeft(t,o-1,dn) t.left(a) tornLeft(t,o-1,dn) def tornRight(t,o,d): if o==0: t.forward(d) else: a = 86.67 dn = 0.47*d tornRight(t,o-1,dn) t.right(a) tornRight(t,o-1,dn) t.left(2*a) tornRight(t,o-1,dn) t.right(a) tornRight(t,o-1,dn) def tornsqLeft(t,n,d): tornLeft(t,n,d) t.left(90) tornLeft(t,n,d) t.left(90) tornLeft(t,n,d) t.left(90) tornLeft(t,n,d) t.left(90) def tornsqRight(t,n,d): tornRight(t,n,d) t.left(90) tornRight(t,n,d) t.left(90) tornRight(t,n,d) t.left(90) tornRight(t,n,d) t.left(90) # ------------- Main Program ---- tony = turtle.Turtle() tony.up() tony.goto(-100,-100) tony.down() tornsqRight(tony, 2, 200)