balance = 3926 annualInterestRate = 0.2 startBalance = balance months = 1 lowbound = balance / 12 print lowbound highbound = (balance * (1 + (annualInterestRate/12))**12)/12 print highbound payment = (lowbound + highbound) /2 while months <= 12: print 'payment ' + str(payment) balance -= payment balance = balance + (balance * (annualInterestRate/12)) print 'balance ' + str(balance) if months == 12 and balance > 0: lowbound = payment payment = (lowbound + highbound) /2 months = 1 balance = startBalance else: months += 1 print 'Lowest Payment: ' + str(payment)
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