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
Principal: 10000 rupees Rate: 8% per year Time: 3 years Simple interest: 2400.00 rupees Total amount: 12400.00 rupees
How it works
- The principal, rate and time are stored in variables, with their units noted in comments.
principal * rate * time / 100applies the formula, dividing by 100 because the rate is a percentage.- The total amount is the principal plus the interest.
:.2finside the f-string prints the money values with exactly two decimal places.
Another way to write it
Using a function, year by year
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.
Related programs
All Python programs · CBSE class 12 practical file · Python exercises