Python program to calculate simple interest; Through this tutorial, i am going to show you how to calculate simple interest in python.
Please look at the formula for calculating the simple interest; as shown below:
(P * N * R)/100
- Where, P is the principal amount
- R is the rate and
- N is the time span
Python Program to Calculate Simple Interest
- Write a Program to Calculate Simple Interest in Python
- Write a Python Program to Calculate Simple Interest using Function
Write a Program to Calculate Simple Interest in Python
- Takes an input from the user.
- Calculate the simple interest using this SI = (P * N * R)/100 formula.
- Print the 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 : 1000 Enter the number of years : 2 Enter the rate of interest : 5 Simple interest : 100.0
Write a Python Program to Calculate Simple Interest using Function
- Define a function in your python program that accepts the argument and calculate simple interest by using this SI = (P * N * R)/100 formula.
- Takes an input from the user.
- Call simple interest function with specific arguments.
- Print the simple interest.
#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 : 1000 Enter the number of years : 2 Enter the rate of interest : 5 Simple interest : 100.0
Recommended Python Programs
Recommended:-Python Math Functions | Built-in Math Function
Recommended:-Python String Methods/Functions
Recommended:-List methods in Python
Recommended:-Python Remove First & Last Character from String
Recommended:-Python Convert String Lowercase to Uppercase
Recommended:-Python Program to Convert Uppercase to Lowercase
Recommended:-Python Program Find Length of String
Recommended:-Python Concatenate String and Variable (int float)
Recommended:-Python Trim String – rstrip(), lstrip(), strip()
Recommended:-Python Dictionary Methods with Example
Recommended:-Python Reverse String
Recommended:-Python String find() Method
Recommended:-Python Replace Character in String
Recommended:-Python Convert String to Float
Recommended:-Python String translate() Method Example
Recommended:-Python Convert String to List
Recommended:-Python filter() Method
Recommended:-Python Map() Method
Be First to Comment