Python program to find Compound interest
In this example, we will learn how to find a compound interest using python.
In this program, we should know the formula and basic concepts to solve the question.
Thus the formula of compound interest is: P(1+R/100)*r
p = principal amount
R= rate of interest
T= time span
- Input the principal amount and rate of interest from the user.
- Input the time in years from the user.
- Using for loop, find the Compound Interest by simply using the above formula.
- Print the result.
n=int(input("Enter the principle amount:")) rate=int(input("Enter the rate:")) years=int(input("Enter the number of years:")) for i in range(years): n=n+((n*rate)/100) print(n)
Enter the principle amount:100 Enter the rate:2 Enter the number of years:2 104.04