Python program to find simple interest; Through this tutorial, You will learn how to calculate or find simple interest in python.
The formula for calculating or finding the simple interest; as shown below:
(P * N * R)/100
Where,
P is the principal amount
R is the rate and
N is the time span
Python Program to Calculate Simple Interest
See the following to write a python program to compute or calculate simple interest using function and without function; as shown below:
- Python Program to Calculate Simple Interest
- Simple Interest Program in Python using Function
1: Python Program to Calculate Simple Interest
- 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
2: Simple Interest Program in Python using Function
- Define a function in your python program that accepts the argument and calculate simple interest by using this SI = (P * N * R)/100 formula.
- Use a python input() function in your python program that takes an input from the user.
- Next, call a simple interest function with specific arguments.
- After the end program, print the simple interest.
#Python program to calculate simple interest using function
def simpleInterest(P, N, R):
SI = (P * N * R)/100
return SI
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 = simpleInterest(P, N, R)
#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