Advertisement
Fareehausman00

Untitled

Sep 21st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #Algorithm for a 2D shape
  2. from turtle import *
  3. from random import randint
  4.  
  5. def random_area():
  6. penup()
  7. x = randint(-100, 100)
  8. y = randint(-100, 100)
  9. goto(x,y)
  10. pendown()
  11.  
  12. def randomColor():
  13. red = (randint(0,255))
  14. green = (randint(0,255))
  15. blue = (randint(0,255))
  16. color(red, green, blue)
  17.  
  18. def surprise(length, height):
  19. random_area()
  20. randomColor()
  21. begin_fill()
  22. forward(length)
  23. right(60)
  24. forward(height)
  25. right(60)
  26. forward(length)
  27. right(60)
  28. forward(height)
  29. right(60)
  30. forward(length)
  31. right(60)
  32. forward(height)
  33. right(60)
  34. end_fill()
  35.  
  36. surprise(50, 50)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement