Programming Assignment #7

Some interesting mathematical functions

Due Date : Wednesday, November 1st

 

Introduction

Once again, this week's assignment is several smaller problems - in this case, some python functions.  Since we are now working with functions it is possible for us to write more than one piece of code inside of a single python file.  For this assignment you should use IDLE to create a single python file titled "pa7.py"  This file should contain each of the functions described below. 


Customer Request #1 (a function called salaryTable() )

You are contacted by Mr. Hiram Cheaply who is the HR director for a local school district. Teachers in his school district are paid on a schedule that provides a salary based on the number of years they have taught in the district. For example, a beginning teacher in the district might make $40,000 the first year. For each year of experience up to 10 years they recieve a 2.25% increase over the previous year.

Write a function called salaryTable():

For example:

 

 


Customer Request #2 (a function called leibniz() )

Your favorite customer - Dr. Al  Gebra - contacts you again.  He reminds you of somewhat well known mathematical function called the Leibniz approximation (http://en.wikipedia.org/wiki/Leibniz_formula_for_pi)  This approximation states that you can estimate pi using the following series:

or

 

Write a function called leibniz().  Rather than run as an infinite summation this function should take in a single parameter named size.  This parameter represents the number of terms in the summation (the number of times that the loop should execute).  Your function should calculate the approximation of pi (don't forget to handle the denominator of 4) and return this approximation.  For example:

 


Customer Request #3 (a function called madhava() )

There actually are many historical approximations of pi.  Let's create another one known as the Madhava approximation of pi.  This appoximation is based on the following sequence (written several ways for clarity).

 

Write a function called madhava().  Again, rather than run as an infinite summation this function should take in a single parameter named size.  This parameter represents the number of terms in the summation (the number of times that the loop should execute).  Your function should calculate the approximation of pi and return this approximation.  For example:

 


 

Submitting your assignment

When you have completed the assignment you should follow the procedures we have been using so far and use the homework submission system to upload the file you were to create for this assignment.

Also, bring printouts of your code to class on the day that it is due.