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
where,
p = principal amount
R= rate of interest
T= time span
Algorithm:
- 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.
- Exit
Code:
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)
Output:
Enter the principle amount:100
Enter the rate:2
Enter the number of years:2
104.04
Report Error/ Suggestion