Way 1 – Calculate Compound Interest
In [1]:
principal = float(input("Enter the principal amount : "))
time = float(input("Enter the time period : "))
rate = float(input("Enter the rate of interest : "))
amount = principal*(1 + (rate/100))**time
compount_interest = amount-principal
print("Compount Interest =", compount_interest)
In this program, we will ask the user to input principal, rate and time. After that, use the compound interest formula.
Way 2 – Compound Interest using power function
In [1]:
principal = float(input("Enter the principal amount : "))
time = float(input("Enter the time period : "))
rate = float(input("Enter the rate of interest : "))
amount = principal*(pow(1 + (rate/100),time))
compount_interest = amount-principal
print("Compount Interest =", compount_interest)
This program is the same as the above program, the only difference is that here we were using the pow() function to find the power.