Skip to content

Instantly share code, notes, and snippets.

@kapv89
Last active December 17, 2015 00:49
Show Gist options
  • Select an option

  • Save kapv89/5523639 to your computer and use it in GitHub Desktop.

Select an option

Save kapv89/5523639 to your computer and use it in GitHub Desktop.
a simple script to calculate the total amount accumulated over a span of years at a given interest rate and an yearly instalment
"""
for a given instalment, interest, and number of years, calculate the compounded amount.
USAGE:
python compound.py instalment interest, years
"""
import sys
def calc(instalment, interest, years):
amount = instalment
for i in range(0, years):
amount = (amount + amount * interest/100.0) + instalment
return amount
def main(script, instalment, interest, years):
instalment, interest, years = float(instalment), float(interest), int(years)
print calc(instalment, interest, years)
if __name__ == '__main__':
main(*sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment