Advertisement
uopspop

Untitled

Oct 10th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. import turtle
  2.  
  3. def draw(t, length, n):
  4.     if n == 0:
  5.         return
  6.     angle = 50
  7.     t.fd(length*n)
  8.     t.lt(angle) ## create flower to the left side
  9.     draw(t, length, n-1)
  10.     t.rt(2*angle) ## create a flower to the right side
  11.     draw(t, length, n-1)
  12.     t.lt(angle) ## turn the direction back
  13.     t.bk(length*n) ## and go back to the previous position
  14.  
  15.  
  16. """
  17. Use cases
  18. """
  19.  
  20. t = turtle.Turtle()
  21.  
  22. draw(t, 10, 5)
  23. # draw(t, 10, 2)
  24.  
  25.  
  26. # wait for the user to close the window
  27. turtle.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement