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 3 degrees and moving a given distance 120 times. Calculate the distance moved with the formula: 2.0*\pi * radius /120.0.(LO: 8.1)
Instructions
Task 1: 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 drawCircle(turtle_obj, x, y, radius):
step_distance =2* math.pi * radius /120.0 # Distance moved per step
turtle_obj.penup() # Do not draw when moving to the start point
turtle_obj.goto(x + radius, y) # Moving to the start point on circumference
turtle_obj.pendown() # Start drawing
for _ in range(120): # Draw the circle through 120 small segments
turtle_obj.left(3) # Turn 3 degrees to the left
turtle_obj.forward(step_distance) # Move forward by the calculated distance
# Setting up the screen (Optional based on environment, useful if running standalone)
turtle.setup(800,600) # Set the window size to 800x600 pixels
# Now, create a turtle object and use the function
my_turtle = turtle.Turtle()
my_turtle.speed(0) # Set the drawing speed to the fastest
# Draw a circle with the center at (0,0) and a radius of 100
drawCircle(my_turtle, 0,0,100)
# 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!