Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 : 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 countpayments 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 i and then subtracting
the payment amount. Store the result back into balance, rounded to 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 $ and is charged a monthly interest rate of Use a loop along
with the function countpayments 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:
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 $ at a
lower monthly interest rate of 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started