Created
November 11, 2021 16:09
-
-
Save ecamellini/c4dcf5181a0f9e51a0522ed50a9c5c97 to your computer and use it in GitHub Desktop.
Compounding interest calculator.
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
""" | |
Compounding interest calculator. | |
""" | |
yearly_deposit = float(input("Yearly deposit: ")) | |
yearly_interest = float(input("Average yearly interest: ")) | |
yearly_multiplier = (100.0 + yearly_interest) / 100.0 | |
years = int(input("Years: ")) | |
total = 0 | |
for i in range(1, years + 1): | |
total = (total + yearly_deposit) * yearly_multiplier | |
print(f"Year {i}: {total} ") | |
print(f"\n\nFinal amount: {total}") | |
print(f"Capital gain (pre-taxes): {total - yearly_deposit * years}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment