Last active
December 17, 2015 00:49
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| 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