Editor

Python Program to Calculate Simple Interest

Beginner · Basics

Simple interest is interest charged or earned only on the original amount, called the principal. It is calculated as SI = P x R x T / 100, where P is the principal, R the yearly rate in percent and T the time in years. This program finds the interest and the total amount at the end.

Program

simple_interest.py
principal = 10000 # amount in rupees
rate = 8 # interest rate in percent per year
time = 3 # time in years
# or: principal = float(input("Enter the principal: ")), and the same for rate and time
simple_interest = principal * rate * time / 100
total_amount = principal + simple_interest
print(f"Principal: {principal} rupees")
print(f"Rate: {rate}% per year")
print(f"Time: {time} years")
print(f"Simple interest: {simple_interest:.2f} rupees")
print(f"Total amount: {total_amount:.2f} rupees")
Output
Principal: 10000 rupees
Rate: 8% per year
Time: 3 years
Simple interest: 2400.00 rupees
Total amount: 12400.00 rupees

How it works

  1. The principal, rate and time are stored in variables, with their units noted in comments.
  2. principal * rate * time / 100 applies the formula, dividing by 100 because the rate is a percentage.
  3. The total amount is the principal plus the interest.
  4. :.2f inside the f-string prints the money values with exactly two decimal places.

Another way to write it

Using a function, year by year

Using a function, year by year
def simple_interest(principal, rate, time):
return principal * rate * time / 100
principal = 10000 # rupees
rate = 8 # percent per year
for years in range(1, 6):
interest = simple_interest(principal, rate, years)
print(f"Year {years}: interest {interest:.2f}, total {principal + interest:.2f} rupees")
Output
Year 1: interest 800.00, total 10800.00 rupees
Year 2: interest 1600.00, total 11600.00 rupees
Year 3: interest 2400.00, total 12400.00 rupees
Year 4: interest 3200.00, total 13200.00 rupees
Year 5: interest 4000.00, total 14000.00 rupees

The function can be reused for any loan or deposit. The interest grows by the same 800 rupees every year, which is what makes it simple interest.

Try it yourself

Change the program so the time is given in months, for example 18 months, and convert it to years before using the formula.

Edit the program above and press Run, or open it in the full editor to save it and share it. To watch it run line by line, open it in the visualizer.

All Python programs · CBSE class 12 practical file · Python exercises