Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that calculates the value of PI and then computes and displays t

ID: 3809598 • Letter: W

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. 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

>, >

Explanation / Answer

import math function to perform square roort functions.

I have written the code without loop. Once I get the error less code with while i would give it.

Mean while a basic code that will help you is below..

import math

radius=input("enter the radius: ")

x=math.sqrt(2)

y=2*(2/x)*(2/math.sqrt(2+x))*(2/math.sqrt(2+(math.sqrt(2+x))))

pi=y

Area=pi*r*r

print area

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote