Advertisement
rickzman

Untitled

Dec 8th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. # draw rectangle with turtle
  2.  
  3. from turtle import Turtle
  4.  
  5. tina = Turtle()
  6.  
  7.  
  8. def rec_area(h, l):
  9. return h * l
  10.  
  11. def rec_perm(h, l):
  12. return h * l * 2
  13.  
  14.  
  15.  
  16. def draw_rec(t_name,h, l, col):
  17. t_name.penup()
  18. t_name.color(col)
  19. t_name.pendown()
  20. t_name.goto(h,0)
  21. t_name.goto(h, l)
  22. t_name.goto(0, l)
  23. t_name.goto(0, 0)
  24. t_name.color("black")
  25. t_name.penup()
  26. t_name.goto (-125, 10)
  27. t_name.pendown()
  28. t_name.write("Area: "+ str(rec_area(h, l)))
  29. t_name.penup()
  30. t_name.goto(-125, -10)
  31. t_name.pendown()
  32. t_name.write("Circumference: "+ str(rec_perm(h, l)))
  33.  
  34.  
  35.  
  36. draw_rec(tina, 200, 300, "blue")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement