Skip to content

Instantly share code, notes, and snippets.

@NicolaM94
Last active June 7, 2023 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NicolaM94/5b6dd5e1516ed9c9105bee2df2576e67 to your computer and use it in GitHub Desktop.
Save NicolaM94/5b6dd5e1516ed9c9105bee2df2576e67 to your computer and use it in GitHub Desktop.
Python script to draw a circle on turtle
import turtle
# Draws a circle from the origin with a given radius
def drawCircle ( turtle :turtle.Turtle, radius :int, origin :tuple=(0,0), penSize :int=1, penColor :str="black", writeLabel :bool=False ) :
turtle.pensize(penSize)
turtle.pencolor(penColor)
turtle.up()
turtle.goto(origin[0],origin[1]-radius)
turtle.down()
turtle.circle(radius)
turtle.up()
if writeLabel:
turtle.goto(origin[0],origin[1])
turtle.down()
turtle.dot()
turtle.write("O",font=("CourierNew",8,"italic"))
turtle.up()
turtle.goto(origin[0],origin[1])
turtle.down()
bob = turtle.Turtle()
drawCircle(bob,150)
turtle.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment