balance = 999999 annualInterestRate = .18 previousBalance = balance updatedBalanceEachMonth = balance numMonths = 1 Step = 100 monthlyInterestRate = (annualInterestRate) / 12.0 monthlyPaymentLowerBound = balance / 12 monthlyPaymentUowerBound = (balance * (1 + monthlyInterestRate)**12) / 12.0 for trial in range(int(monthlyPaymentLowerBound)*Step, int(monthlyPaymentUowerBound)*Step,1): minimumFixedMonthlyPayment = 1.0 * trial/Step for numMonths in range(1,13): monthlyUnpaidBalance = (previousBalance) - (minimumFixedMonthlyPayment) updatedBalanceEachMonth = (monthlyUnpaidBalance) + (monthlyInterestRate * monthlyUnpaidBalance) previousBalance = updatedBalanceEachMonth if previousBalance < 0: break else: previousBalance = balance updatedBalanceEachMonth = balance print 'Lowest Payment: ' + str(minimumFixedMonthlyPayment)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question