Python Program to calculate the simple interest


March 2, 2022, Learn eTutorial
980

In this simple python program, we need to find simple interest. It's an intermediate-level python program.

To understand this example, you should have knowledge of the following Python programming topics:

What is simple interest?

In this solved python program, we need to calculate the Simple Interest, which can be calculated using the formula SI = p*n*r / 100. where

  • p is the principal amount.
  • n is the number of years.
  • r is the rate of interest.

For example, suppose we take a loan of the amount 1000 with an interest rate of 10% for 1 year. Then calculating the simple interest by the formula pnr/100 gives 1000 * 10 * 1 / 100 = 100. so we have to give 100rs as interest for 1 year.

How is simple interest calculated in python?

Now apply this logic in the python programming language. We accept the values for the principal amount, interest rate, and time in years using the input function in python language. Then we calculate the interest by using the formula ( p * n * r ) / 100.

ALGORITHM

STEP 1: Accept the values for the principal amount, time, and rate of interest using the input function in python language. Convert the values to an integer using float and int data type.

STEP 2: Calculate the simple interest using the formula (p*n*r) / 100.

STEP 3: Use a print statement in the python programming language to print the value of simple interest.

Python Source Code

                                          principle=float(input("Enter the amount :"))

time=int(input("Enter the years :"))

rate=float(input("Enter the rate :"))

si=(principle*time*rate)/100

print("The simple interest is:", si)
                                      

OUTPUT

Enter the amount : 1000

Enter the year : 1

Enter the rate : 10

The simple interest is : 100