Python Program to Find Simple Interest

Problem Description

Write a Python program that calculates simple interest based on the principal amount, interest rate, and time period provided.

What is Simple Interest?

Simple Interest is a basic financial concept used to calculate the interest earned or paid on a principal amount over a certain period of time, based on a fixed interest rate.his is a Python Program to compute simple interest given all the required values.

Some common terms in the calculation of Simple interest:

  • Principal: The initial amount of money borrowed or invested.
  • Interest Rate: The percentage applied to the principal to calculate the interest.
  • Time Period: The duration for which the money is borrowed or invested, typically measured in years.
Problem Solution

1. Take in the values for principle amount, rate and time.
2. Using the formula, compute the simple interest.
3. Print the value for the computed interest.
4. Exit.

Formula to Calculate Simple Interest:

Simple Interest = (P × R × T)/100
Here, P = Principal Amount, R = Rate of Interest and T = Time.

Example:

Find the Simple Interest on Rs. 200 for 5 years at 5% per annum compounded annually.

Solution:

advertisement
advertisement

Given, P = 200, R = 5 and T = 5.

Simple Interest (SI) = (P * R * T)/100

SI = (200 * 5 * 5)/100
SI = 5000/100
SI = 50

Hence, the Simple Interest on Rs.200 at the rate of 5% for 5 years is Rs. 50

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
Program/Source Code

Here is source code of the Python Program to compute simple interest given all the required values. The program output is also shown below.

 
principle=float(input("Enter the principle amount:"))
time=int(input("Enter the time(years):"))
rate=float(input("Enter the rate:"))
simple_interest=(principle*time*rate)/100
print("The simple interest is:",simple_interest)
Program Explanation

1. User must enter the values for the principle amount, rate and time.
2. Calculate the simple interest using the formula: (principal*time*rate)/100
3. Print the calculated simple interest.

Time Complexity: O(1)
The time complexity of the given program is O(1) because the execution time is constant and does not depend on the input size.

advertisement

Space Complexity: O(1)
The space complexity of the program is O(1) as well because the amount of memory used by the program remains constant regardless of the input size.

Runtime Test Cases

Testcase 1: In this case, enter P=200, R=5, and T=5 as the parameters to calculate simple interest.

Enter the principle amount:200
Enter the time(years):5
Enter the rate:5.0
The simple interest is: 50.0

Testcase 2: In this case, enter P=70000, R=4, and T=1 as the parameters to calculate simple interest.

Enter the principle amount:70000
Enter the time(years):1
Enter the rate:4.0
The simple interest is: 2800.0

To practice programs on every topic in Python, please visit “Programming Examples in Python”.

advertisement

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.