formula for compounding interest in python

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)

Here is what the above code is Doing:
1. It’s asking the user to input the starting principle, the number of compounding periods per year, the annual interest rate, and the amount of years.
2. It’s storing the user’s input in the variables P, n, r, and y.
3. It’s calculating the final value of the investment after y years.
4. It’s printing the final value of the investment after y years.