SHARE
TWEET

CS-A1-Worksheet1

maincarry May 15th, 2016 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '''
  2. Part 1: Loan
  3.  
  4. By Mark Wu 3217
  5. '''
  6.  
  7. def calculateMonthlyPayment(principal, annualInterestRate, duration):
  8.     try:
  9.         r = annualInterestRate / 100 / 12 # r is the monthly interest rate
  10.         n = duration * 12 # n is the total month
  11.         monthlyPayment = (principal * r * (r + 1) ** n) / ((r + 1) ** n - 1)
  12.         return monthlyPayment
  13.     except:
  14.         return 'Error'
  15.  
  16. # print(calculateMonthlyPayment(1000.0, 4.5, 5))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top