Advertisement
richbpark

Turtle2.py

Jan 22nd, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. from turtle import Turtle
  2.  
  3. T1 = Turtle()
  4.  
  5. def circleArea(radius):
  6. return 3.14 * radius * radius
  7.  
  8. def circleCircumference(radius):
  9. return 3.14 * radius * 2
  10.  
  11. def drawCircle (tName, radius, col):
  12. tName.color(col)
  13. tName.dot(2 * radius)
  14.  
  15. tName.penup()
  16. tName.goto(0,10) # Move turtle to x = 0, y = 10
  17. tName.pendown()
  18. tName.color ("black")
  19. tName.write("Area: " + str(circleArea(radius)), align = "center", font=("Arial", 24, "normal"))
  20.  
  21. tName.penup()
  22. tName.goto(0,-20) # Move turtle to x = 0, y = -20
  23. tName.pendown()
  24. tName.write("Circ: " + str(circleCircumference(radius)), align = "center", font=("Arial", 24, "normal"))
  25. tName.hideturtle()
  26.  
  27. drawCircle (T1, 150, "yellow")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement