compound interest program in python

In this example, you will find compound interest in python based on user input.

To calculate compound interest, we use the following formula :

    
P(1 + R / 100)T
    

Here, P = Principal, R = Rate of Interest in % per annum, and T = time in years.

Example :

    
# Python program to find Compound interest
 
# User input
p = float(input("Enter the principle amount: "))
r = float(input("Enter the rate of interest: "))
t = float(input("Enter the time period: "))

# calculating compound interest
ci =  p * (pow((1 + r / 100), t)) 

print("Compound interest is :: " ,format(ci))
       

Output :

    
Enter the principle amount: 1250
Enter the rate of interest: 8.6
Enter the time period: 2
Compound interest is ::  1474.2450000000001
    

Share your thoughts

Ask anything about this examples