Question
Write a program that calculates the value of PI and then computes and displays the area of a circle with radius entered by the user.
Write a program that calculates the value of PI and then computes and displays the area of a circle with radius entered by the user. PI must be approximated using the following formula. Note that this formula has an infinite number of terms with increasing complexity, so you must multiply additional terms until the size of the next term is 1!
Hint: This problem requires the use of a 'while' loop to accumulate each term. Also, use the round function to display the computed values with 3 decimal places e.g. round(5.23517, 3) is 5.235.
Formula:
Approximation of pi: 3.142
Enter the radius: 2.5
Area: 19.635
Below is the formula that I have been given:
Sample I/O: Approximation of pi: 3.142 Enter the radius: 2.5 Area: 19.635 Save your program as pi.py
>, >Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started