Write a Python program that calculates the area and the circumference of a circle whose radius is described by the equation: r=√(x−h)2+(y−k)2 Your code must have a main( ) and a getValues(center, point) functions. The main function reads data from an input file, which has the format shown below. Each line in the file starts with a serial number followed by h, k, x, and then y (see Fig. 1). For each circle, the function getValues(center, point) receives two lists center (containing h and k) and point (containing x and y). Then it returns a list containing the radius, area and circumference of the circle use Equation 1 and 2 below. area= π r2 ----------------------------(1) circumference=2 π r ----------------(2) This list is received by the main function and it is written it in an output file. In addition to that, your main function will count how many circles have a circumference less than 50. Note: You program must be general and works for any number of experiments. All reading and writing must be done in the main function. Please include the file names in the program and no need to ask the user for file names. Sample input file below: (you can copy/paste and save below data as text file for input) 1 4.64 1.74 7.83 0.12 2 4.76 1.45 7.1 3.36 3 5.61 1.83 5.76 2.25 4 0.58 9.44 6.89 2.61 5 0.2 4.08 4.53 5.88 Sample output file below: Sn Radius Area Circumference 1 3.58 40.26 22.49 2 xxxx xxxx xxxx 3 xxxx xxxx xxxx 4 xxxx xxxx xxxx 5 xxxx xxxx xxxx Number of circles with Circumference less than 50 units = 4
Write a Python program that calculates the area and the circumference of a circle whose radius is described by the equation: r=√(x−h)2+(y−k)2 Your code must have a main( ) and a getValues(center, point) functions.
|
- The main function reads data from an input file, which has the format shown below. Each line in the file starts with a serial number followed by h, k, x, and then y (see Fig. 1).
- For each circle, the function getValues(center, point) receives two lists center (containing h and k) and point (containing x and y). Then it returns a list containing the radius, area and circumference of the circle use Equation 1 and 2 below.
area= π r2 ----------------------------(1)
circumference=2 π r ----------------(2)
- This list is received by the main function and it is written it in an output file.
- In addition to that, your main function will count how many circles have a circumference less than 50.
Note:
You program must be general and works for any number of experiments.
All reading and writing must be done in the main function.
Please include the file names in the program and no need to ask the user for file names.
Sample input file below: (you can copy/paste and save below data as text file for input)
1 4.64 1.74 7.83 0.12
2 4.76 1.45 7.1 3.36
3 5.61 1.83 5.76 2.25
4 0.58 9.44 6.89 2.61
5 0.2 4.08 4.53 5.88
Sample output file below:
Sn Radius Area Circumference
1 3.58 40.26 22.49
2 xxxx xxxx xxxx
3 xxxx xxxx xxxx
4 xxxx xxxx xxxx
5 xxxx xxxx xxxx
Number of circles with Circumference less than 50 units = 4
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)