You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
843 B

#!/usr/bin/python
starting = int(input("Starting amount: "))
monthly = int(input("What is your monthly contribution? "))
interest = float(input("What is your yearly interest rate (computed monthly; 0.05 = 5%)? "))
interest_pm = interest/12
term = int(input("How long are you calculating for (in whole years)? "))
def compute_new_sum(principle, investment, pm_interest):
return principle * (1+pm_interest)
def compute_new_sum_yr(principle, investment, interest):
total = principle
for month in range(12):
total += investment
total = compute_new_sum(total, investment, interest/12)
return total
total = starting
print("Year,Total,Principle,PDV")
for year in range(term):
total = compute_new_sum_yr(total, monthly, interest)
princ = (year+1) * monthly * 12
pdv = total - princ
print(f"{year+1},{total},{princ},{pdv}")