define a function drawCircle. This function should expect a Turtle object, the c
ID: 3535809 • Letter: D
Question
define a function drawCircle. This function should expect a Turtle object, the coordinates of the circle's center
point, and the circle's radius as arguments.The function should draw the specified circle. The pen color should be
changed to yellow before drawing a circle and the width of the pen to 5 pixels. The algorithm should draw the circle's circumference by turning 3 degrees and moving a given distance 120 times. Calculate the distance moved with the
formula 2.0*n*radius/120.0. Fill in the circle with blue color. After drawing the circle, hide the turtle.
My instructor told me that I have to use the formula not the circle function to make this work.
Thank you!
import turtle
import math
def drawCircle(centerpoint, radius):
degree = 3
count = 0
centerpoint = (2.0 * math.pi * radius / 120)
t.home()
t.setheading(degree)
while count <= 120:
t.down()
t.forward(2.0 * math.pi * radius / 120)
t.up()
degree += 3
t.setheading(degree)
count += 1
drawCircle(centerpoint, radius)
Explanation / Answer
"""
Program: 7_1.py
Author: kkasp
Function drawCircle
-Expect Turtle object, coordinates of the circle's center point and
circle's radius as arguments
-Function draws circle
-Draw circle's circumference by turning 3 degrees and moving a given
distance, 120 times.
-Calculate the distance moved with formula 2.0 * 3.14 * radius /120
"""
def drawCircle (turtle, centerpoint, radius):
circumference = 2 * 3.14 * (radius/120)
print "The circumference moved is", circumference
turtle.up()
(x,y) = centerpoint[-1]
turtle.turn(3)
turtle.move(120)
turtle.down()
from turtlegraphics import Turtle
turtle=Turtle()
drawCircle(turtle, [(20,20)], 20)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.