CSCI 107 Assignment 7
- Due Date: Wednesday, November 9th no later than 11:59 p.m.
- Partner Information: You may complete this assignment individually or
with exactly one classmate.
- Submission Instructions (working alone): Upload your solution,
entitled YourFirstName-YourLastName-Assignment7.py
to the BrightSpace Assignment 7 Dropbox.
- Submission Instructions (working with one classmate): Upload your
solution, entitled
YourFirstName-YourLastName-PartnerFirstName-PartnerLastName-Assignment7.py
to the BrightSpace Assignment 7 Dropbox. Note: If you work with a
partner, only one person needs to submit a solution. If you both
submit a solution, the submission that will be graded is the one from
the partner whose last name comes alphabetically first.
- Deadline Reminder: Once the submission deadline passes, BrightSpace
will no longer accept your submission and you will no longer be able
to earn credit. Thus, if you are not able to fully complete the
assignment, submit whatever you have before the deadline so that
partial credit can be earned.
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
- 10 points - A function named leibniz_pi_estimate
exists (4 points) with the appropriate two parameters
(3 points each).
- 45 points - The function will be tested on 3 different sets
of inputs. The correctness of each test is worth 20 points.
- 15 points - A while loop is used correctly in the missing
function. (All or nothing).
- 15 points - The output format of the transcript is matched exactly.
(5 points for each type of difference.)
- 15 points - The Python solution is commented correctly,
easy to understand and does not contain unnecessary code
(3 points per type of improvement possible). Remember to provide
a comment for the function.