In this challenge we will create a library of functions to apply the different formulas based on the geometry of circles.
For each function, you will need to design the algorithm using either Pseudo-code or a flowchart, implement the function using the Python trinket provided below and use another algorithm to test your function.
Write a function called getCircumference() that takes one parameter/argument: the radius of a circle.
Your function should calculate and return the circumference (perimeter) of this circle..
Write an algorithm to test your function.
Your algorithm should:
- Ask the user to enter the length of the radius of a circle,
- Use the getCircumference() function to retrieve the circumference of the circle,
- Display the circumference of the circle
Write a function called getArea() that takes one parameter/argument: the radius of a circle.
Your function should calculate and return the area of this circle..
Write an algorithm to test your function.
Your algorithm should:
- Ask the user to enter the length of the radius of a circle,
- Use the getArea() function to retrieve the area of the circle,
- Display the area of the circle
Write a function called getArcLength() that takes two parameters/arguments: the radius and angle of an arc.
Your function should calculate and return the length of this arc..
Write an algorithm to test your function.
Your algorithm should:
- Ask the user to enter the length of the radius of a circle,
- Ask the user to enter the angle of an arc,
- Use the getArcLength() function to retrieve the length of this arc,
- Display the length of the arc.
Write a function called getSectorPerimeter() that takes two parameters/arguments: the radius and angle of a sector.
Your function should calculate and return the perimeter of this sector..
Write an algorithm to test your function.
Your algorithm should:
- Ask the user to enter the length of the radius of a circle,
- Ask the user to enter the angle of a sector,
- Use the getSectorPerimeter() function to retrieve the perimeter of this sector,
- Display the perimeter of this sector.
Write a function called getSectorArea() that takes two parameters/arguments: the radius and angle of a sector.
Your function should calculate and return the area of this sector..
Write an algorithm to test your function.
Your algorithm should:
- Ask the user to enter the length of the radius of a circle,
- Ask the user to enter the angle of a sector,
- Use the getSectorArea() function to retrieve the area of this sector,
- Display the area of this sector.
Write a function called getChordLength() that takes two parameters/arguments: the radius and angle of a chord.
Your function should calculate and return the length of this chord..
Write an algorithm to test your function.
Your algorithm should:
- Ask the user to enter the length of the radius of a circle,
- Ask the user to enter the angle of a chord,
- Use the getChordLength() function to retrieve the lenght of the chord,
- Display the length of the chord
Write a function called getSegmentPerimeter() that takes two parameters/arguments: the radius and angle of a segment.
Your function should calculate and return the area of this segment..
Write an algorithm to test your function.
Your algorithm should:
- Ask the user to enter the length of the radius of a circle,
- Ask the user to enter the angle of a segment,
- Use the getSegmentPerimeter() function to retrieve the perimeter of this segment,
- Display the perimeter of the segment
Write a function called getSegmentArea() that takes two parameters/arguments: the radius and angle of a segment.
Your function should calculate and return the area of this segment..
Write an algorithm to test your function.
Your algorithm should:
- Ask the user to enter the length of the radius of a circle,
- Ask the user to enter the angle of a segment,
- Use the getSegmentArea() function to retrieve the area of this segment,
- Display the area of the segment
Python Code
We have already started the code for you and have completed the function getCircumference() followed by a short algorithm to test this function.
Your task is to complete this Python script to create and test all the functions mentioned above.