Simple Interest Program in Python
A formula program seen in almost every beginner exam. It reads three values and applies the simple interest formula.
Quick answer
Simple interest is SI = P × R × T / 100, where P is the principal, R the rate in per cent per year and T the time in years. In Python: si = p * r * t / 100. For P = 37000, R = 4 and T = 3 the interest is 4440.0 and the total amount is 41440.0.
The question
Read the principal, the rate of interest (% per year) and the time in years — three integers, one per line. Print the simple interest SI = P × R × T / 100.
The code
program.py
p = int(input())
r = int(input())
t = int(input())
si = p * r * t / 100
print("Simple Interest =", si)Input
37000 4 3
Output
Simple Interest = 4440.0
How it works
- 1Read principal p, rate r (per cent per year) and time t in years.
- 2Simple interest is p × r × t / 100.
- 3Print the result; since / is used, it prints with a decimal point.
Step by step for P = 37000, R = 4, T = 3
| Step | Python | Value |
|---|---|---|
| P × R × T | 37000 * 4 * 3 | 444000 |
| ÷ 100 | 444000 / 100 | 4440.0 |
| Amount = P + SI | 37000 + 4440.0 | 41440.0 |
The / operator always gives a float in Python 3, which is why the answer prints as 4440.0.
Common mistakes
- Forgetting to divide by 100 — the rate is a percentage.
- Reading all three values on one line when the question gives them on separate lines.
With decimal values and the total amount
A rate such as 7.5% is not a whole number, so read the values with float(). The total amount to pay back is the principal plus the interest.
program.py
p = float(input())
r = float(input())
t = float(input())
si = p * r * t / 100
print("Simple Interest =", si)
print("Total Amount =", p + si)Input
5000 7.5 2
Output
Simple Interest = 750.0 Total Amount = 5750.0
Simple interest using a function
When the question says "write a function", put the formula inside def and return the answer instead of printing it.
program.py
def simple_interest(p, r, t):
return p * r * t / 100
print("Simple Interest =", simple_interest(10000, 8, 3))Input
(no input)
Output
Simple Interest = 2400.0
Questions students ask
- What is the formula for simple interest in Python?
- si = p * r * t / 100, where p is the principal, r is the rate of interest in per cent per year and t is the time in years. The * and / operators are worked out from left to right.
- Why does the answer print as 2400.0 and not 2400?
- The / operator in Python 3 always returns a float, even when the division is exact. Write int(si) or use // 100 only if the question asks for a whole number.
- How do I find the total amount?
- Add the interest to the principal: amount = p + si. For ₹5,000 at 7.5% for 2 years the interest is ₹750 and the amount is ₹5,750.
Now solve a similar question yourself
A new Python question every time, checked instantly.
Preparing for NIELIT O Level?
This program is the kind asked in the M3 (Python) theory paper and the PR-3 practical exam.
Want to build websites and apps with AI tools instead of writing every line yourself? See our AI Digital Pro course in Kaithal.
