Skip to content

Instantly share code, notes, and snippets.

@ecamellini
Created November 11, 2021 16:09
Show Gist options
  • Save ecamellini/c4dcf5181a0f9e51a0522ed50a9c5c97 to your computer and use it in GitHub Desktop.
Save ecamellini/c4dcf5181a0f9e51a0522ed50a9c5c97 to your computer and use it in GitHub Desktop.
Compounding interest calculator.
"""
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