Advertisement
xavicano

Untitled

Aug 1st, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. '''   At the moment all our circles are drawn at the centre of the screen. Can you add parameters to the draw_circle function so that you can
  2.         draw circles at different locations on the screen?
  3.        The goto(x, y) function moves the turtle to a specific location.
  4.        The penup() function lifts the pen so that the turtle doesn’t draw when it’s moving.
  5.        What do you think is the best order for the input parameters for your function?
  6.  
  7.    Can you create a similar function that draws rectangles of different sizes and shapes? You can look at the Modern Art project
  8.    for help with drawing rectangles.
  9.  
  10.    Use your functions to draw a picture or create some art.
  11. '''
  12.  
  13. from turtle import *
  14. from time import sleep
  15.  
  16. tina = Turtle()
  17.  
  18.  
  19. def draw_circle(x,y,t_name, r, col, shape):
  20.     t_name.goto(x,y)
  21.     t_name.pendown()
  22.    
  23.     t_name.color(col)
  24.     if shape=="circle":
  25.         t_name.dot(r*2)
  26.     else:
  27.         t_name.shape(shape)
  28.     t_name.penup()
  29.  
  30.  
  31. draw_circle(5,5,tina, 150, "blue","turtle")
  32. draw_circle(100,100,tina, 100, "red","square")
  33. draw_circle(20,100,tina, 50, "yellow","circle")
  34.  
  35. sleep(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement