P = int(input("Enter starting principle please. "))
n = int(input("Enter number of compounding periods per year. "))
r = float(input("Enter annual interest rate. e.g. 15 for 15% "))
y = int(input("Enter the amount of years. "))
FV = P * (((1 + ((r/100.0)/n)) ** (n*y)))
print ("The final amount after", y, "years is", FV)
def compound_interest(initial_amount, rate, periods_elapsed):
return initial_amount * (1 + (rate/100))**periods_elapsed
# Example: 100 of money, 5 %, 12 months passed
print(compound_interest(100, 5, 12)) # -> 179.5856
# The formula:
# A = P(1 + r/100)^t