data science - Need some help trying to get my Python mortgage amortization calculator to work properly -


so, starting graduate program in data science in spring 2018 , trying acquainted python before then, having difficulty problem working on force myself better understand how works.

here exact description of problem:

in problem, create mortgage calculator takes input principal loan amount, interest rate, , monthly payment. output, calculator should generate amortization table, , compute how many years , months took pay off mortgage, , report total amount of payments on time.

in mortgage, bank lends amount of principal purchase house @ interest rate. every month, amount owe (the balance) first increases due interest: 1/12 of interest rate times current balance. balance decreases due monthly payment. example, suppose borrow $100,000 @ 5% annual interest, $500 monthly payments. in first month, interest increases balance $416.67, , payment reduces $500, remaining balance of $99,916.67. in second month, interest charge $416.32, , remaining balance $99,832.99.

if continue process, amortization table this:

mortgage amortization table

you can compute total amount of time , money pay off mortgage. in example, takes 35 years , 11 months, , total amount paid approximately $215,458.84.

here things consider when implementing calculator:

  1. for dollar values, display 2 digits of precision after decimal point. (you can assume banke not round internally).
  2. the final payment smaller others, careful check case don’t end negative balance.
  3. if monthly payment small, balance go every month! if happens, program should stop , display appropriate error message.
  4. if accidentally create infinite loop, try interrupt or restart kernel.
  5. use modulus % operator separate years , months.
  6. your program should display columns requested, , rows should formatted appear under appropriate heading.

here code have far:

loanamount = 100000 interestrate = 5 monthlypayment = 500  monthlyinterest = round((loanamount * interestrate/100/12),2) monthlybalance = float(loanamount - (monthlypayment - monthlyinterest))   print ("month", "\t\t", "payment", "\t\t", "interest", "\t\t\t", "balance") print ("-----", "\t\t", "-------", "\t\t", "--------", "\t\t\t", "-------")  month = 0  while monthlybalance > 0 :         month += 1  ##### stuck , think need “for” loop in here, lost #####          print (month, "\t\t", monthlypayment, "\t\t\t", interest, "\t\t\t", balance) 

here mortgage amortization table being created using existing code above, looks nothing mortgage amortization table above rows 2 , on:

my mortgage amortization table

however, need each value in interest , balance columns decrease rather have same values , need with.

any support here gurus appreciated.

thank all.


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -