Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- balance = 320000
- annualInterestRate = 0.20
- monthlyInterestRate = annualInterestRate / 12
- MonthlyPaymentLowerBound = balance / 12
- MonthlyPaymentUpperBound = balance * ((1 + monthlyInterestRate)**12 / 12)
- balance2=balance
- ans=round((MonthlyPaymentLowerBound + MonthlyPaymentUpperBound) / 2.0+0.01, 8)
- while True:
- for month in range(12):
- balance2=balance2-ans
- balance2=balance2 + balance2 * monthlyInterestRate
- if abs(balance2) < 0.08:
- break;
- if balance2 > 0:
- MonthlyPaymentLowerBound=ans
- elif balance2 < 0:
- MonthlyPaymentUpperBound=ans
- ans=round((MonthlyPaymentUpperBound+MonthlyPaymentLowerBound)/ 2.0+0.01,8)
- balance2=balance
- print('Lowest payment: ' + str(round(ans,2)))
Add Comment
Please, Sign In to add comment