Python Practice › Basic Programs › Program 20
Simple interest
Write a Python program to calculate simple interest. Simple interest = P × R × T / 100, where P is the principal, R the yearly rate in percent and T the time in years.
Input
P = 10000, R = 6.5, T = 3
Output
Simple interest: 1950.0 Total amount: 11950.0
Approach
- Apply the formula.
- Add the interest to the principal for the total amount.
Solution
principal = 10000rate = 6.5years = 3 interest = principal * rate * years / 100amount = principal + interestprint("Simple interest:", interest)print("Total amount:", amount)Output
Simple interest: 1950.0 Total amount: 11950.0
Line by line
Line 5
Dividing by 100 converts the percentage rate into a fraction.
Line 6
The amount repaid is the principal plus the interest.
Note
The original version of this exercise listed the formula as P + (P/r)*t, which is not the simple interest formula. The correct formula is P × R × T / 100.
Learn the concept
New to this topic? Read the lesson, then come back.