Python Program to Calculate Simple Interest

Python Program to Calculate Simple Interest

Python program to find simple interest; Through this tutorial, You will learn how to calculate or find simple interest in python.

The formula for calculating or finding 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

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

  • Python Program to Calculate Simple Interest
  • Simple Interest Program in Python using Function

1: Python Program to Calculate Simple Interest

  • Use a python input() function in your python program that takes an input from the user.
  • Next, calculate the simple interest using this SI = (P * N * R)/100  formula.
  • After the end program, 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 

2: Simple Interest Program in Python 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.
  • Use a python input() function in your python program that takes an input from the user.
  • Next, call a simple interest function with specific arguments.
  • After the end program, 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

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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