Simple Interest Calculator Mathematical Logic
Python Code
principal = float(input("Enter Principal Amount: "))
rate = float(input("Enter Rate of Interest (%): "))
time = float(input("Enter Time Period (in years): "))
simple_interest = (principal * rate * time) / 100
print("Simple Interest is:", simple_interest)
Step-by-Step Explanation
1. Taking User Inputs:
float(input(...)) takes user inputs for Principal, Rate, and Time, converting them into floating-point numbers to support decimal values.
2. Understanding the Formula: The standard formula for Simple Interest is
SI = (P × R × T) / 100.
3. Performing Calculation:
(principal * rate * time) / 100 multiplies all three inputs together and divides the result by 100.
4. Storing the Result: The calculated simple interest value is assigned to the variable
simple_interest.
5. Displaying Output:
print(...) displays the calculated simple interest clearly on the screen.
Worked Example: P = 1000, R = 5, T = 2
Initial Inputs: principal = 1000.0, rate = 5.0, time = 2.0
| Variable | Formula Step | Calculation | Result |
|---|---|---|---|
| Product (P * R * T) | 1000.0 * 5.0 * 2.0 | 10000.0 | Intermediate |
| Simple Interest | 10000.0 / 100 | 100.0 | simple_interest = 100.0 |
Final Output: Simple Interest is: 100.0