Simple Interest Program in Python

Simple Interest Program in Python | Simple interest is a quick and easy method of calculating the interest charge on a loan. We will give the principal amount, Rate of Interest, and Time. Simple interest is determined by multiplying the daily interest rate by the principal by the number of days that elapse between payments. In this post, Python program to calculate simple interest using various methods.

Simple Interest Formula:

Simple Interest = ( P x R x T ) / 100
Where,
P is the principal amount
R is the rate of interest and
T is the time (number of years)

Mathematically,

Input : P = 1000
R = 5
T = 10
Simple Interest = (1000 x 5 x 10) / 100 = 500

Now let’s see how we can implement a simple interest calculator in
Python.

Python Program to Calculate Simple Interest

This is the simplest and easiest way to calculate the simple interest in Python. In this program, Inputs (Principal amount, Interest rate, and time) will be provided by the user. The principal amount is stored in the variable P, interest rate in R, and time in T. Now, calculate the simple interest using the formula. Then, simple interest and the total amount are displayed using the print() function.

Program description:- Write a Python program to calculate the simple interest

# Python program to calculate simple interest

# store the inputs
P = float(input('Enter principal amount: '))
R = float(input('Enter the interest rate: '))
T = float(input('Enter time: '))

# calculate simple interest
SI = (P * R * T) / 100

# display result
print('Simple interest = ',SI )
print('Total amount = ',( P + SI ))

Output for the different input values:-

Enter principal amount: 1000
Enter the interest rate: 5
Enter time: 10
Simple interest = 500.0
Total amount = 1500.0

Enter principal amount: 7000
Enter the interest rate: 7.5
Enter time: 5
Simple interest = 2625.0
Total amount = 9625.0

Enter principal amount: 25000
Enter the interest rate: 3.8
Enter time: 7.4
Simple interest = 7030.0
Total amount = 32030.0

Inputs are scanned using the input() function. input() method reads user input as a string. So, we need to convert it to float first.

P = float(input('Enter principal amount: '))
R = float(input('Enter the interest rate: '))
T = float(input('Enter time: '))

Python Program to Find Simple Interest using Function

This is a different way to calculate simple interest in python. We can also take the help of function. A function is a block of code that performs a specific task.

# Python program to calculate simple interest using function

def calculate_simple_interest(P, R, T):
    # calculate simple interest
    SI = (P * R * T) / 100
    return SI;

if __name__ == '__main__':
    # store the inputs
    P = float(input('Enter principal amount: '))
    R = float(input('Enter the interest rate: '))
    T = float(input('Enter time: '))

    # calling function
    simple_interest = calculate_simple_interest(P, R, T)
    # display result
    print('Simple interest = %.2f' %simple_interest)
    print('Total amount = %.2f' %(P + simple_interest))

Output:-

Enter principal amount: 15000
Enter the interest rate: 5.4
Enter time: 20
Simple interest = 16200.00
Total amount = 31200.00

In this program, we will be the first defined function. Inputs are scanned using the input() function and stored in variables P, R and T. Then call the function and print the simple interest and total amount.

If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!

Also See:- Python Program to Add Two Numbers

Leave a Comment

Your email address will not be published. Required fields are marked *