Answered step by step
Verified Expert Solution
Link Copied!

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 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago