How to Calculate Simple Interest In Python?

17-Oct-2022

.

Admin

How to Calculate Simple Interest In Python?

Hi Dev,

This article is focused on How To Calculate Simple Interest In Python. This article goes in detailed on Write a program to calculate simple interest in Python . In this article, we will implement a Simple Interest Program in Python. I would like to show you Program to find the simple interest in python. You just need to some step to done python program simple interest using Function.

See the following to write a python program to compute or calculate simple interest using function and without function; as shown below:

let's see below simple example with output:

Example 1: Python Program to Calculate Simple Interest


#Python program to calculate simple interest

P = float(input("Enter the principal amount : "))

N = float(input("Enter the number of years : "))

R = float(input("Enter the rate of interest : "))

#calculate simple interest by using this formula

SI = (P * N * R)/100

#print

print("Simple interest : {}".format(SI))

Output:

Enter the principal amount : 10000

Enter the number of years : 2

Enter the rate of interest : 5

Simple interest : 1000.0

Example 2: Simple Interest Program in Python using Function

#Python program to calculate simple interest using function

def simpleInterest(P, N, R):

SI = (P * N * R)/100

return SI

P = float(input("Enter the principal amount : "))

N = float(input("Enter the number of years : "))

R = float(input("Enter the rate of interest : "))

#calculate simple interest by using this formula

SI = simpleInterest(P, N, R)

#print

print("Simple interest : {}".format(SI))

Output:

Enter the principal amount : 10000

Enter the number of years : 2

Enter the rate of interest : 5

Simple interest : 1000.0

I hope it can help you...

#Python