Programme to find the simple interest using Python

by | Feb 13, 2021 | Python Programs

Home » Python » Python Programs » Programme to find the simple interest using Python

Introduction

In this section of python coding, we will learn to calculate the simple interest. As we already know the mathematical expression to calculate the simple interest understand the code logic will be easier.

Programme to find the simple interest using Python

Let us look into the python code for calculating simple interest.

Program

def interest(p, r, t):
    amount = float(p)
    rate = float(r)
    time = float(t)
    s_interest = float((amount*rate*time)/100)
    print("Simple interest of principle amount {0} , rate of interest {1} and time period {2} is {3}".format(amount,rate,time,s_interest))
   
# User input
p = input("Enter the principle amount: ")
r = input("Enter the rate of interest: ")
t = input("Enter the time period: ")
interest(p,r,t)

OUTPUT

Programme to find the simple interest using Python Output

Explanation

In the above code, we have created a function interest(). The user inputs for principal amount, rate and time period are scanned through input() function and passed to the function interest() for calculating the simple interest and then storing the result in the variable s_interest.

Author

0 Comments

Submit a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Author