Created
August 12, 2015 00:47
-
-
Save marinho/74e6986fa981ad166696 to your computer and use it in GitHub Desktop.
This file contains 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
def calc_savings(years=10, monthly=500, rate=1.12, initial=0.): | |
""" | |
years = amount of years to saving money | |
monthly = amount saved per month (inflation is ignored) | |
rate = rate per year to apply. Must be 1 + annual interest rates | |
initial = initial amount to startup | |
""" | |
total = initial | |
for n in range(years): | |
total = (total + monthly * 12) * rate | |
print('Year #{}:\t{}'.format(n + 1, round(total, 2))) | |
return round(total, 2) | |
assert calc_savings(monthly=700, rate=1.12, initial=2000) == 171310.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment