Question

In: Computer Science

In Python: Define a function drawCircle. This function should expect a Turtle object, the coordinates of...

In Python:

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. This function should draw the specified circle. The algorithm should draw the circle’s circumference by turning 3 degree and moving a given distance 120 times. Calculate the distance moved with the formula 2.0*π*radius/120.0.

Solutions

Expert Solution

code

import turtle

from math import pi

def draw_circle(myTurtle, x, y, radius):

myTurtle.penup()

myTurtle.setposition(x, y-radius) # move to the position x,y-radius where x ,y will be center

myTurtle.pendown()

for i in range(120):

myTurtle.circle(radius, 3)

turtle.getscreen().mainloop()

distance_moved = 2.0*pi*radius/120.0

return distance_moved

myTurtle = turtle.Turtle()

distance = draw_circle(myTurtle, 200,200 ,50)

on console:

   
2.61799387799
   

print(distance)


Related Solutions

Define a function drawCircle. This function should expect a Turtle object, the coordinates of the circle’s...
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 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 × π × radius ÷ 120.0. Define a function main that will draw a circle with the following parameters when the program is...
Define a function drawCircle. This function should expect a Turtle object, the coordinates of the circle’s...
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 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 × π × radius ÷ 120.0. Define a function main that will draw a circle with the following parameters when the program is...
No other code on this website works. Define a function drawCircle. This function should expect a...
No other code on this website works. 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 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 × π × radius ÷ 120.0. Define a function main that will draw a circle with...
Python question Define a function called max_value_length(tree) that takes a Binary Tree object as a parameter...
Python question Define a function called max_value_length(tree) that takes a Binary Tree object as a parameter and returns an integer that contains the longest character length of all the values in that tree. Use recursion. For example, the character length of value 123 is 3, because there are three digits. The character length of value “Ruru” is 4, because it has four characters. Further, the max_value_length() function would return 4 if the only node values in the tree were 123...
Write a function that draw your initials. (Using python 3 turtle) (T, S)
Write a function that draw your initials. (Using python 3 turtle) (T, S)
Write a function that plots the following trajectory equations using python turtle graphics. x = v*sin(A)*t...
Write a function that plots the following trajectory equations using python turtle graphics. x = v*sin(A)*t y = v*cos(A)*t -.5*(9.8)*t**2 Loop through t starting at 0 and increment by .1 until y<=0. (hint, while loop) Experiment with values of velocity V (1 to 20) and angle A (0 to 90) that gives you a good plot that does not go off the screen. Position the start of the plot at the left bottom of the screen
PYTHON: Write a function insertInOrder that takes in a list and a number. This function should...
PYTHON: Write a function insertInOrder that takes in a list and a number. This function should assume that the list is already in ascending order. The function should insert the number into the correct position of the list so that the list stays in ascending order. It should modify the list, not build a new list. It does not need to return the list, because it is modifying it.   Hint: Use a whlie loop and list methods lst = [1,3,5,7]...
. Create a Python function that asks the user for a number (integer). The function should...
. Create a Python function that asks the user for a number (integer). The function should then tell the user how many hundreds can go into the number, and how much is left over. Hint: the % operator calculates the remainder of a division. For example, 10 % 3 gives a result 1. Hint2: Deal with the positive and negative values in separate parts of an if-else structure. Get the calculation work for positive values first. For negative values, make...
Write a Python function that receives a stack object s, where the items in the stack...
Write a Python function that receives a stack object s, where the items in the stack are only numbers in the set {0,1} and returns the number of 1's in the stack s. The function must satisfy the following restrictions: the state of the stack must be preserved; ie., after calling this function the state of the stack s must be the same it was before the function was called. The function cannot use any additional variables of any of...
is it possible to have more than one ellipse on python turtle.
is it possible to have more than one ellipse on python turtle.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT