Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def payYear(startbalance, balance, minpayment, monthlyinterest, upper, lower):
- while balance > 0.01:
- month = 1
- while month <13:
- balance = (balance - minpayment) * ( 1 + monthlyinterest)
- month +=1
- if balance > 0.01:
- balance = startbalance
- upper = minpayment
- elif balance < 0:
- lower = minpayment
- minpayment = (upper+lower)/2.0
- return minpayment
- balance = 320000
- startbalance = balance
- annualInterestRate = 0.2
- monthlyinterest = annualInterestRate/12
- lower = balance/12
- upper = (balance*(1+monthlyinterest)**12)/12
- minpayment = (upper+lower)/2.0
- ans = payYear(startbalance, balance, minpayment, monthlyinterest, upper, lower)
- print "minpayment is: " + str(round(ans, 2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement