Articles

# Python program to calculate compound interest

In this Python programming guide, we will learn to:

• write a program to compute compound interest in python

### Program to find the Compound Interest in Python

The program to find the compound interest in python is as follows:

``````# Owner : TutorialsInhand Author : Devjeet Roy

principle = float(input("Enter the principle: "))
rate = float(input("Enter the rate of interest: "))
time = float(input("Enter the time: "))

amount = principle * (pow((1 + rate / 100), time))
ci = amount - principle

print("Compound interest is", round(ci,2)) ``````

The output of the program to find the compound interest in python is as follows:

``````PS C:\Users\DEVJEET\Desktop\tutorialsInHand> python code.py
Enter the principle: 10000
Enter the rate of interest: 10.25
Enter the time: 5
Compound interest is 6288.95``````

1. First of all, we ask the user to enter the principle, rate and time and thereafter we convert each one of them to perform mathematical computations.

2. Then we use the formula for compound interest to find the amount. Thereafter we deduct principle from amount to get the compound interest.

3. Lastly, we round off the answer upto 2 decimal places.

The snapshot is given below for program - python program to calculate compound interest: Basic Python Programs

Would you like to see your article here on tutorialsinhand. Join Write4Us program by tutorialsinhand.com 