This is a simple interest calculator that computes the simple interest based on the principal amount, time period in years, and annual rate of interest.
- p: Principal amount
- t: Time period in years
- r: Annual rate of interest
Simple Interest = p * t * r
For instance, if you have a principal amount of $1000, a time period of 3 years, and an annual interest rate of 5%, you can calculate the simple interest as follows:
Simple Interest = $1000 * 3 years * 0.05 (5%) = $150
You can use this simple interest calculator in your code to determine the interest amount for a given principal, time period, and interest rate.
def calculate_simple_interest(p, t, r):
return p * t * r
# Example usage
principal = 1000
time_period = 3
annual_rate = 0.05 # 5%
simple_interest = calculate_simple_interest(principal, time_period, annual_rate)
print(f"Simple Interest: ${simple_interest}")