Simple interest formula is given by: Simple Interest = (P x T x R)/100 Where, P is the principal amount T is the time and R is the rate
Examples:
Input : P = 10000
R = 5
T = 5
Output :2500.0
We need to find simple interest on
Rs. 10,000 at the rate of 5% for 5
units of time.
Python Program for simple interest
Python3
def simple_interest(p,t,r):
print ( 'The principal is' , p)
print ( 'The time period is' , t)
print ( 'The rate of interest is' ,r)
si = (p * t * r) / 100
print ( 'The Simple Interest is' , si)
return si
simple_interest( 8 , 6 , 8 )
|
Output
The principal is 8
The time period is 6
The rate of interest is 8
The Simple Interest is 3.84
Time complexity: O(1)
Auxiliary Space: O(1)
Program for simple interest with Taking input from user
We can calculate the simple interest by taking P,T and R from the user.
Python3
def simple_interest(p,t,r):
print ( 'The principal is' , p)
print ( 'The time period is' , t)
print ( 'The rate of interest is' ,r)
si = (p * t * r) / 100
print ( 'The Simple Interest is' , si)
P = int ( input ( "Enter the principal amount :" ))
T = int ( input ( "Enter the time period :" ))
R = int ( input ( "Enter the rate of interest :" ))
simple_interest(P,T,R)
|
Output:
Input:
Enter the principal amount :3000
Enter the time period :7
Enter the rate of interest :1
Output:
The simple interest is 210.0
Time complexity: O(1)
Auxiliary Space: O(1)
#Please refer complete article on Program to find simple interest for more details!
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!