1. Introduction
Simple interest is a quick method of calculating the interest charge on a loan. Simple interest is determined by multiplying the daily interest rate by the principal by the number of days that elapse between payments. In Python, this concept can be translated into a straightforward program.
Simple Interest (SI) is calculated using the formula: SI = (Principal amount * Rate of Interest * Time) / 100. It's the product of the principal, the rate of interest per period, and the time periods.
2. Program Steps
1. Define the principal amount, rate of interest, and time period.
2. Calculate the simple interest using the formula.
3. Print the calculated simple interest.
3. Code Program
# Function to calculate simple interest
def calculate_simple_interest(principal, rate, time):
# Calculate simple interest using the formula
simple_interest = (principal * rate * time) / 100
return simple_interest
# Principal amount, rate of interest, and time period
principal_amount = 1000
interest_rate = 5
time_period = 3
# Calculate the simple interest
simple_interest = calculate_simple_interest(principal_amount, interest_rate, time_period)
# Print the simple interest
print(f"The simple interest is: {simple_interest}")
Output:
The simple interest is: 150.0
Explanation:
1. A function named calculate_simple_interest is defined with parameters principal, rate, and time.
2. The function computes the simple interest using the given formula and returns the result.
3. The variables principal_amount, interest_rate, and time_period are set to 1000, 5, and 3, respectively.
4. calculate_simple_interest is called with these values to calculate the simple interest.
5. The calculated simple interest, 150.0, is printed.
6. The f-string is used in the print statement for clear and formatted output.
Comments
Post a Comment
Leave Comment