Question

In: Computer Science

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 run:

  • X = 50
  • Y = 75
  • Radius = 100

Solutions

Expert Solution

Code:

import turtle
def drawCircle(turtle, x, y, radius):
turtle.penup()
#setting the given co-ordinates (50,75)
turtle.setposition(x, y)
#turns 3 degree
turtle.left(3)
#moving forward 120 times
turtle.forward(120)
turtle.pendown()
#drawing the circle of given radius 100
turtle.circle(radius)
turtle.getscreen()._root.mainloop()
#printing the distance moved
print("Distance Moved:",((2 * 3.14 * radius ) / 120))

turt= turtle.Turtle()#turtle object
x = 50
y = 75
radius = 100#declaring variables
drawCircle(turt, x, y, radius)
#calling the function

Output:

Indentation:


Related Solutions

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...
The coordinates of an object moving in the XY plane vary with time according to the...
The coordinates of an object moving in the XY plane vary with time according to the equations  x = −7.43 sin ωt and y = 4.00 − 7.43 cos ωt, where ω is a constant, x and y are in meters, and t is in seconds. (a) Determine the components of the velocity of the object at t = 0. (Use the following as necessary: ω.) (b)  Determine the components of the acceleration of the object at t = 0. (Use the...
The coordinates of an object moving in the xy plane vary with time according to the...
The coordinates of an object moving in the xy plane vary with time according to the equations x = −5.08 sin ωt and y = 4.00 − 5.08 cos ωt, where ω is a constant, x and y are in meters, and t is in seconds. (a) Determine the components of velocity of the object at t = 0. (Use the following as necessary: ω.) v with arrow = m/s (b) Determine the components of the acceleration of the object...
You should assume that there will be an object file named “foreignsub.o” which implements a function...
You should assume that there will be an object file named “foreignsub.o” which implements a function whose prototype is given in the header file “foreignsub.h”. The header file “foreignsub.h” consists of the following line. int sub(int n, int *A, int *B, int *C); However, you do not know what this function does exactly. For your testing purpose, you may produce such a function, e.g., returning the maximum value among the 3n integers in the three arrays. You are also given...
Create a class named GameCharacter to define an object as follows: The class should contain class...
Create a class named GameCharacter to define an object as follows: The class should contain class variables for charName (a string to store the character's name), charType (a string to store the character's type), charHealth (an int to store the character's health rating), and charScore (an int to store the character's current score). Provide a constructor with parameters for the name, type, health and score and include code to assign the received values to the four class variables. Provide a...
Define the term: Flotation Costs. Should we expect the flotation costs for debt to be significantly...
Define the term: Flotation Costs. Should we expect the flotation costs for debt to be significantly lower than those for equity? Why or why not? Please support your answer using supporting information from the chapters in this unit and the course. Do you agree with the positions taken by your classmates? Can you provide counterpoints or insight as to why they may want to reconsider their view of expected flotation costs?
Define the term: Flotation Costs. Should we expect the flotation costs for debt to be significantly...
Define the term: Flotation Costs. Should we expect the flotation costs for debt to be significantly lower than those for equity? Why or why not? Please support your answer using supporting information from the chapters in this unit and the course. Do you agree with the positions taken by your classmates? Can you provide counterpoints or insight as to why they may want to reconsider their view of expected flotation costs?
Define two C structures, one to represent rectangular coordinates and one to represent polar coordinates. Rewrite...
Define two C structures, one to represent rectangular coordinates and one to represent polar coordinates. Rewrite the rec_to_polar function to use variables declared using the new structures.
write the Hamiltonian, the Green's function and the Schrodinger equation in spherical coordinates
write the Hamiltonian, the Green's function and the Schrodinger equation in spherical coordinates
  The stream function in cylindrical coordinates for a two-dimensional flow is given by:                          &nbsp
  The stream function in cylindrical coordinates for a two-dimensional flow is given by:                                     Ψ = [(a)(r) + (b)/(r)] Sin ϴ Where “a” and “b” are constants. a)Does this flow satisfy the continuity? b)Determine the corresponding velocity potential in the polar coordinate system. c) Is this flow irrotational? Why?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT