Question

In: Computer Science

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 following parameters when the program is run:

  • X = 25
  • Y = 75
  • Radius = 100

Solutions

Expert Solution

Thanks for the question.

Below is the code you will be needing  Let me know if you have any doubts or if you need anything to change.

Thank You !
===========================================================================

import turtle


def drawCircle(t, x, y, radius):
    t.penup()
    t.goto(x, y)
    t.right(90)
    t.forward(radius)
    t.left(90)
    t.pendown()
    for _ in range(120):
        t.left(3)
        t.forward(2.0 * 3.14159265 * radius / 120)
    t.penup()
    t.goto(x, y)

def main():
    t = turtle.Turtle()
    canvas = turtle.Screen()

    drawCircle(t, 25, 75, 100)
    canvas.exitonclick()


main()


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...
Write code to define a function named mymath. The function has three arguments in the following...
Write code to define a function named mymath. The function has three arguments in the following order: Boolean, Integer, and Integer. It returns an Integer. The function will return a value as follows: 1. If the Boolean variable is True, the function returns the sum of the two integers. 2. If the Boolean is False, then the function returns the value of the first integer - the value of the second Integer.
Modify the original code and add an additional function of your choice. The function should be...
Modify the original code and add an additional function of your choice. The function should be unique and something you created for this assignment. Support your experimentation with screen captures of executing the new code. Prepare a test table with at least 3 distinct test cases listing input and expected output for your unique function. #include <stdio.h> void printHelp () { printf ("\n"); printf ("a: a(x) = x*x\n"); printf ("b: b(x) = x*x*x\n"); printf ("c: c(x) = x^2 + 2*x...
Define and test a function myRange. This function should behave like Python’s standard range function, with...
Define and test a function myRange. This function should behave like Python’s standard range function, with the required and optional arguments, but it should return a list. Do not use the range function in your implementation! Study Python’s help on the range to determine the names, positions, and what to do with your function’s parameters. Use a default value of None for the two optional parameters. If these parameters both equal None, then the only provided argument should be considered...
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?
Explain how you can secure passwords and other sensitive data on a website. Provide code snippets...
Explain how you can secure passwords and other sensitive data on a website. Provide code snippets to explain your approach. Your answer can be based on the use of PHP/MySQL or ASP.NET/SQL based solution. Explain how online advertisements will be stored and served.
Exercise Define a function that generates a random code. The functions takes in a string colors...
Exercise Define a function that generates a random code. The functions takes in a string colors whose characters represent distinct colors to choose from, and a positive integer code_length representing the length of the code. For instance, get_code('ROYGBP',4) returns a code of 4 code pegs randomly with colors chosen from 'R'ed, 'O'range, 'Y'ellow, 'G'reen, 'B'lue, and 'P'urple. One possible outcome is 'ROYY'. Following is my python code, and I don't know how to continue, can someone help me to finished...
Write python 3 code to define a function that uses three arguments, and returns a result....
Write python 3 code to define a function that uses three arguments, and returns a result. The function returns True if the first argument is more than or equal to the second argument and less than or equal to the third argument, otherwise it returns False. Write a python 3 code for function main, that does the following: creates a variable and assign it the value True. uses a while loop which runs as long as the variable of the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT