p = 5 # interest rate per year n = 3 # number of years A = 1000 # initial amount (in Euros) final = A*(1 + p/100.0)**n print '''{A:g} Euros have grown to {final:g} Euros after {n:g} years at an interest rate of {p:g}% per year.'''.format(A=A, final=final,n=n,p=p) ''' Sample run: 1000 Euros have grown to 1157.63 Euros after 3 years at an interest rate of 5% per year. '''
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