Advertisement
here2share

# t_Sierpinski_Triangle.py

Jan 9th, 2021
918
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. # t_Sierpinski_Triangle.py
  2.  
  3. import turtle
  4. Window = turtle.Screen()
  5.  
  6. Window.bgcolor('white')
  7. turtle.color('white')
  8.  
  9. def serp_tri(side):
  10.     turtle.goto(-side/2, -side/2.3)
  11.     side = side*1.0
  12.     def triangle(side):
  13.         if side > 3:
  14.             for i in range(3):
  15.                 turtle.color('black')
  16.                 turtle.ht()
  17.                 turtle.fd(side)
  18.                 turtle.left(120)
  19.             turtle.pu()
  20.             if int(side) < 10:
  21.                 turtle.pd()
  22.             turtle.ht()
  23.             triangle(side/2)
  24.             turtle.fd(side/2)
  25.             triangle(side/2)
  26.             turtle.bk(side/2)
  27.             turtle.left(60)
  28.             turtle.fd(side/2)
  29.             turtle.right(60)
  30.             triangle(side/2)
  31.             turtle.left(60)
  32.             turtle.bk(side/2)
  33.             turtle.right(60)
  34.     turtle.speed(0)
  35.     triangle(side)
  36.  
  37. serp_tri(600)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement