balance = 4213 monthlyPaymentRate = 0.04 annualInterestRate = 0.20 monthlyInterestRate = annualInterestRate / 12.0 totalpaid = 0 for i in range(1,13): #def monthlyPayment(): # x = balance * monthlyPaymentRate # return x monthlyPayment = balance * monthlyPaymentRate totalpaid += monthlyPayment balance = balance - monthlyPayment balance = balance + (balance * monthlyInterestRate) print "Month:", i print "Minimum monthly payment:", round(monthlyPayment,2) print "Remaining balance:", round(balance,2) print "Total paid:", round(totalpaid, 2) print "Remaining balance:", round(balance, 2)
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