Question: Your Tasks Define a function drawCircle ( in the file circle.py ) . This function should expect a Turtle object, the coordinates of the circle
Your Tasks
Define a function drawCircle in the file circle.py This function should expect a Turtle object, the coordinates of the circles center point, and the circles radius as arguments. The function should draw the specified circle. The algorithm should draw the circles circumference by turning degrees and moving a given distance times. Calculate the distance moved with the formula: pi radius LO:
Instructions
Task : Define the drawCircle function so that it draws the specified circle.
NB: This question has already been answered on Chegg but it doesn't work.This is the code I used:
import turtle
import math
# Function to draw a circle
def drawCircleturtleobj, x y radius:
stepdistance math.pi radius # Distance moved per step
turtleobj.penup # Do not draw when moving to the start point
turtleobj.gotox radius, y # Moving to the start point on circumference
turtleobj.pendown # Start drawing
for in range: # Draw the circle through small segments
turtleobj.left # Turn degrees to the left
turtleobj.forwardstepdistance # Move forward by the calculated distance
# Setting up the screen Optional based on environment, useful if running standalone
turtle.setup # Set the window size to x pixels
# Now, create a turtle object and use the function
myturtle turtle.Turtle
myturtle.speed # Set the drawing speed to the fastest
# Draw a circle with the center at and a radius of
drawCirclemyturtle,
# To keep the window open until the user closes it
turtle.done
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
