Python Program to Calculate Simple and Compound Interest

Python program to calculate simple and compound interest; In this tutorial, you will learn how to calculate simple interest and compound interest in python.
Python Program to Calculate Simple and Compound Interest
See the following to python program to calculate simple interest and compound interest; as shown below:
- Python Program to Calculate Simple Interest
- Python Program to Compute Compound Interest
Python Program to Calculate Simple Interest
Use the following steps to write a program to calculate simple interest in python:
- Use a python input() function in your python program that takes an input from the user.
- Next, calculate the simple interest using this SI = (P * N * R)/100 Â formula.
- After the end program, print the simple interest.
#Python program to calculate simple interest
P = float(input("Enter the principal amount : "))
N = float(input("Enter the number of years : "))
R = float(input("Enter the rate of interest : "))
#calculate simple interest by using this formula
SI = (P * N * R)/100
#print
print("Simple interest : {}".format(SI))
Output
Enter the principal amount : 1000 Enter the number of years : 2 Enter the rate of interest : 5 Simple interest : 100.0
Python Program to Compute Compound Interest
Use the following steps to write a program to calculate compound interest in python:
- Use a python input() function in your python program that takes an input (principal amount, rate of interest, time) from the user.
- Next, calculate the compound interest using this p * (pow((1 + r / 100), t)) Â formula.
- After the end program, print the compound interest.
#Python program to compute compound interest
p = float(input("Enter the principal amount : "))
t = float(input("Enter the number of years : "))
r = float(input("Enter the rate of interest : "))
#compute compound interest
ci = p * (pow((1 + r / 100), t))
#print
print("Compound interest : {}".format(ci))
Output
Enter the principal amount : 1000 Enter the number of years : 2 Enter the rate of interest : 5 Compound interest : 1102.5
Recommended Python Programs
Recommended:-Leap Year Program in Python
Recommended:-Python Program to Print Star Pattern
Recommended:-Number Pattern Programs in Python
Recommended:-Python Abs() Function: For Absolute Value
Recommended:-Python: Program to Find Power of Number
Recommended:-Python Program to Reverse a Numbers
Recommended:-Python Program to Find Smallest/Minimum of n Numbers
Recommended:-Python Program to Find Largest/Maximum of n Numbers
Recommended:-Python Program to Print Numbers Divisible by 3, 5, 7
Recommended:-Python Program to Print Prime Number 1 to N
Recommended:-How to Find Square of Number in Python
Recommended:-Python Program to Calculate Cube of Number



