Question: Problem 2 : Amortization In this problem, we will create a function that counts the number of monthly payments required to pay back a loan

Problem 2: Amortization
In this problem, we will create a function that counts the number of monthly payments required to pay back a loan
Define a function named count_payments(). The function should accept three parameters: amount, rate, and pmt.
The parameter amount represents the initial size of a loan that is to be repaid with monthly payments. The parameter
rate is the monthly rate at which the loan collects interest, and pmt is the size of the monthly payment.
The function should calculate and return the number of monthly payments required to repay the loan. This is calculated
by using a loop. Every time the loop executes, the following steps should be performed:
Calculate the new balance. This will be done by multiplying the current balance by 1+i, and then subtracting
the payment amount. Store the result back into balance, rounded to 2 decimal places.
Increment a variable used to count the number of payments that have been made.
The loop should continue to run for as long as the balance is greater than zero.
The function should not print anything. It should not create any new lists, and should involve only one loop.
We will now test the function. Create a new code cell for the instructions below.
Assume that a loan is made in the amount of $160,000 and is charged a monthly interest rate of 0.4%. Use a loop along
with the function count_payments() to determine the number of monthly payments that must be made in order to
repay the loan, assuming that the payments are in the size of each of the following values:
850,900,950,1000,1050
Each time the loop executes, the message shown below should be displayed, with the xxxx symbols replaced with the
appropriate values. Match the format exactly. Do not include extra spaces.
xxxx monthly payments of $xxxx would be required.
For full credit, I would like for you to use a formula to determine the new payment amount each time the loop
executes, rather than creating a list to store the payment amounts. However, if you use a list to store the payments,
you will get partial credit.
Let's test the function with a different set of values. Create a new code cell for the instructions below.
Assume that the borrower mentioned in the previous set of instructions has an opportunity to borrow the $160,000 at a
lower monthly interest rate of 0.35%. Repeat the instructions from the previous cell using the new interest rate. Use the
same payments amounts as before.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!