Last active
June 7, 2023 19:50
-
-
Save NicolaM94/5b6dd5e1516ed9c9105bee2df2576e67 to your computer and use it in GitHub Desktop.
Python script to draw a circle on turtle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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