Python program to calculate compound interest

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
Enter the principle: 10000
Enter the rate of interest: 10.25
Enter the time: 5
Compound interest is 6288.95

Few important tips about this program

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:

how to find compound interest in python


Basic Python Programs

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

About the Author
Devjeet Roy
Full Stack Web Developer & Blockchain Enthusiast
Page Views :    Published Date : Feb 04,2021  
Please Share this page

Related Articles

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!