Python Practice › Basic Programs › Program 20

Simple interest

EasyBasic Programs · 20 of 40

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.

Advertisement
Input
P = 10000, R = 6.5, T = 3
Output
Simple interest: 1950.0
Total amount: 11950.0

Approach

  1. Apply the formula.
  2. Add the interest to the principal for the total amount.

Solution

Python
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.

Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More basic programs

← All 40 Basic Programs