teromakotero

Draw circle

May 5th, 2019
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. '''
  2. At the moment all our circles are drawn at the centre of the screen.
  3. Can you add parameters to the draw_circle function so that you can draw circles at different locations
  4. on the screen?
  5.  
  6. The goto(x, y) function moves the turtle to a specific location.
  7. The penup() function lifts the pen so that the turtle doesn’t draw when it’s moving.
  8. What do you think is the best order for the input parameters for your function?
  9. '''
  10. from turtle import Turtle
  11.  
  12. drawer = Turtle()
  13.  
  14. def draw_circle(turtle_name, r, color, x, y):
  15.     turtle_name.color(color)
  16.     turtle_name.penup()
  17.     turtle_name.goto(x,y)
  18.     turtle_name.pendown()
  19.     turtle_name.dot(r*2)
  20.    
  21. draw_circle(drawer, 10, "red", 100, 100)
Advertisement
Add Comment
Please, Sign In to add comment