Question: For this problem, you will write a program called PiApproximator that approximates the mathematical constant by summing a finite number of terms in a

For this problem, you will write a program called PiApproximator that approximates

For this problem, you will write a program called PiApproximator that approximates the mathematical constant by summing a finite number of terms in a series for it. The series you will use is = 4- 4.4 4.4 4 + 11 + 415 + ... For this problem, you will use a while loop to keep adding terms as long as the magnitude (or absolute value; for example, the magnitude of -2 is 2; there is a Python function that computes this) of the added term (including the factor of 4) is greater than 1e-6. Your program should output both 1. the approximation at that point, and 2. a count of the number of terms that have been summed in producing that approximation. Notes: We talked about this series in Lecture 7. You can copy the notebook linked here to start: https://colab.research.google.com/drive/1iQil1252K-wmEkILLAFXmPSbfd1zgAh2#scrollTo=ddBziXoNoIzH Hint: you will be changing the for loop to a while loop, using a threshold instead of , adding variables/lines to count the number of terms added, and altering the print statement to print the desired outputs First debug your program using a larger threshold (say 0.01 vs. 1e-6); see the linked PS3 FAQ for more details on this. Turn in: Cut-and-paste of your code, with the output that it produces embedded as comments at the point they are printed out in the program (just cut-and-paste the text output after your print statement(s), then either surround by or put in front of each output line). Make sure to re-run your program after inserting the indicated comments to make sure they are actually only comments and do not affect your program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here is the python code to achieve the results mainpy Initialize variables approximation 0 count 0 W... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!