timpin

Untitled

Aug 24th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. from turtle import Turtle
  2. from random import *
  3. tina = Turtle()
  4.  
  5. def circle_area(r):
  6. return 3.14159 * r * r
  7.  
  8. def circle_circumference(r):
  9. return 3.14159 * 2 * r
  10.  
  11. def draw_circle(t_name, r, col):
  12. t_name.color(col)
  13. t_name.dot(2 * r)
  14.  
  15. t_name.penup()
  16. t_name.goto(0,5) #Assumes circle is at 0,0.
  17. t_name.pendown()
  18. t_name.color("black")
  19. t_name.write("Area: " + str(circle_area(r)), align="center")
  20.  
  21. t_name.penup()
  22. t_name.goto(0,-5)
  23. t_name.pendown()
  24. t_name.color("black")
  25. t_name.write("Circumference: " + str(circle_circumference(r)), align="center")
  26.  
  27. def draw_rectangle(t_name,x,y,col):
  28. t_name.hideturtle
  29. t_name.color(col)
  30. t_name.pendown()
  31. t_name.begin_fill()
  32. t_name.goto(0,y)
  33. t_name.goto(x,y)
  34. t_name.goto(x,0)
  35. t_name.goto(0,0)
  36. t_name.end_fill()
  37.  
  38. draw_rectangle(tina,50,70,"blue")
  39.  
  40.  
  41. #draw_circle(tina,25,"red")
Advertisement
Add Comment
Please, Sign In to add comment