CSCI 107 Assignment 7


Estimating Pi

The purpose of this assignment is to give you more experience using while loops to solve problems.

For this assignment, you will write a program to estimate the value of pi using the Leibniz formula.

Starting Python Program

Download and rename assignment7.py according to the instructions above. Do not modify any of the provided code. All you need to do is to supply the missing function and update the comments as appropriate.

Sample Output Transcript

This transcript shows three runs of the program. The user enters (1) the desired precision of the estimate, a non-negative number and (2) the maximum number of trials to reach this desired precision, a non-negative integer. The missing function is then called. The initial estimate for pi/4 is 1 and Trial 1 produces an estimate of 2/3 (1 - 1/3). The function should continue running until either the desired precision is reached or the maximum number of trials have been conducted. The desired precision is reached when the absolute difference between two consecutive estimates is less than the value that the user requested.

Requirements and Grading