Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- loan_balance = 500000
- annual_interest_rate = 4.5/100
- total_repayments = 360 #Monthly repayments for a 30 year home loan
- monthly_interest_rate= annual_interest_rate/12
- min_repayment_amount = -np.pmt(monthly_interest_rate, total_repayments, loan_balance)
- principal_paid = 0
- payment_number = 1
- while payment_number <= 10:
- interest_part = -np.ipmt(monthly_interest_rate, payment_number, total_repayments, loan_balance)
- principal_part = -np.ppmt(monthly_interest_rate, payment_number, total_repayments, loan_balance)
- print(round(min_repayment_amount, 2), "|", round(interest_part, 2), "|", round(principal_part, 2))
- principal_paid += principal_part
- payment_number += 1
- print("Balance after payment# 10:", loan_balance - principal_paid)
- '''
- Output
- 2533.43 | 1875.0 | 658.43
- 2533.43 | 1872.53 | 660.9
- 2533.43 | 1870.05 | 663.37
- 2533.43 | 1867.56 | 665.86
- 2533.43 | 1865.07 | 668.36
- 2533.43 | 1862.56 | 670.86
- 2533.43 | 1860.05 | 673.38
- 2533.43 | 1857.52 | 675.91
- 2533.43 | 1854.99 | 678.44
- 2533.43 | 1852.44 | 680.98
- Balance after payment# 10: 493303.50660926406
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement