Starting from:
$35

$29

Program 1 Solution

Learning objectives:

 
Create a Python program on your own.

 
Develop a simple Python program that asks for input, does arithmetic, and provides output.




Assignment:

You and many of your friends will be buying cars and homes within the next few years. As a result you have decided to write a Python program to calculate the principal payments and help everyone realize exactly how much interest they will pay over the period of their loans. In order to perform the appropriate calculations, you will need to know the initial loan amount (“principal”), the number of months of the loan (“months”), and the interest rate (“interest”). Your program should calculate the principal payment for each month, the amount paid over the life of the loan, and the total interest paid.




The formulas you will need are:




rate = interest / 1200




principal (rate ((1+rate)months)

monthly payment = ------------------------------

(1+rate)months - 1




Note: have the user input the interest rate as it appears before dividing it by 100. For example, if the interest rate is 5.3% the user should enter 5.3 NOT .053.




Save your program as usury.py.




Guidance:

You may be wondering if there are any Express II classes that sound enjoyable as you contemplate dropping CSCI220. Don’t leave yet! While the problem may seem difficult, applying the software development cycle will help. Ask yourself, and write the answers to, the following questions. Add your answers as a comment to your .py file.

 
What will the program do? (Purpose statement)




 
What will be the inputs and outputs? (Part of header.)




 
Provide a step-by-step list of what your program must do, aka an algorithm. (Remember this is in English! Add these to body of your code as comments for the code.)




 
Implement your code.




 
Test your program using the sample runs below.




Principal/ Loan Amount
Months
Interest
Monthly Payment (calculated)
Total amount paid (calculated)
Total interest paid (calculated)
$ 1000
36
5%
$ 29.9708971047
$ 1078.95229577
$ 78.952295768
$ 40000
60
7.5%
$ 801.517943825
$ 48091.0766295
$ 8091.0766295
$ 250000
360
7%
$ 1663.25623795
$ 598772.245661
$ 348772.245661
$ 10000
120
5.5%
$ 108.52627796
$ 13023.1533553
$ 3023.15335526



File to be submitted:

usury.py




Policies:

The policies expressed in Policy.doc will be in place for this and all future assignments.

More products