Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Part 2: Loan
- By Mark Wu 3217
- '''
- def calculateRemainingLoanBalance(principal, annualInterestRate, duration, number_of_payments):
- try:
- n = duration * 12 # n is the total month
- if annualInterestRate != 0:
- r = annualInterestRate / 100 / 12 # r is the monthly interest rate
- else:
- r = principal / n
- p = number_of_payments
- result = principal * ((1+r)**n - (1+r)**p) / ((1+r)**n - 1)
- return result
- except:
- return 'Error'
- # print(calculateRemainingLoanBalance(1000.0, 4.5, 5, 12))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement