Quote of AWESOMENESS: “Good software, like wine, takes time.” ~ Joel Spotsky
Helloooo!
Back again with another Python Project! Isn’t it just great?
yes. yes, it is.
Anyways! Let’s jump right into it.
The function we will be making today is one that is (extremely) awesome. We will be making out very own function that makes circles by itself! Once created, all a person has to do when using your function would be putting in the argument area the size, color, locations and other specifics that one would usually want to specify.
# remember that when we put a hashtag we are making a comment # first thing to do is import the turtle library that comes with python from turtle import * # next, is the setup setup() # here, we are putting a title to the program we will be creating title("Olympic Function") turtle = Turtle() # you can change the color if you'd like it's just for the background screen color bgcolor("white") # now, here is where the magic begins! # when making a function we must use the keyword def # you can change the name of the function (it's the draw_ring one that you can change the name to whatever you would like) # inside the () beside the function we just defined, we put in our arguments def draw_ring(x,y,turtlecolor,size,turtle): # once the function gets called, the turtle.up() would put the pen we will be using for drawing up turtle.up() # this tells the turtle where to go, it's location turtle.goto(x,y) # then, the pen goes down and it ready to start drawing on the screen with turtle.down() turtle.down() # here's a cool thing we add to our function to add some color and life to our circle turtle.color(turtlecolor) # this would, as you may see in the args (a.k.a argument), chooses the size of the circle turtle.circle(size) # finally, once the circle is created successfully and the function is done, the turtle hides turtle.hideturtle() ############################### ###### TESTING SECTION ###### # here's where we test our creation! # try it out! call your function then put in the specifics of your circle draw_ring(-250,0,"red",75,turtle) draw_ring(-80,0,"pink",75,turtle) draw_ring(90,0,"red",75,turtle) draw_ring(-165,-75,"pink",75,turtle) draw_ring(90,0,"red",75,turtle) draw_ring(7,-75,"pink",75,turtle) done()
Here’s the result of the function above!
AWESOMENESSSSSSSSSSSSSS! TRY IT OUT AND HAVE FUN!
Hope you’re having an amazing day 🙂
Yours truly,
L.O.A.S.H
© Elizabeth Anne Villoria