In this activity, we will build a Loan Interest Calculator using user-defined functions. The program will calculate both Simple Interest and Compound Interest based on user input.

Interest Formulas
Writing the Script
# Loan Interest Calculator def simple_interest(principal, rate, time): si = (principal * rate * time) / 100 return si def compound_interest(principal, rate, time): amount = principal * ((1 + rate / 100) ** time) ci = amount - principal return ci # Get inputs principal = float(input("Enter the principal amount: ")) rate = float(input("Enter the interest rate (%): ")) time = float(input("Enter the time period (years): ")) # Calculate si = simple_interest(principal, rate, time) ci = compound_interest(principal, rate, time) # Display results print("--- Results ---") print("Simple Interest: " + str(round(si, 2))) print("Total Amount (SI): " + str(round(principal + si, 2))) print("Compound Interest: " + str(round(ci, 2))) print("Total Amount (CI): " + str(round(principal + ci, 2)))
Testing the Program
- Run with Principal = 10000, Rate = 5, Time = 3
- Simple Interest should be 1500.0, Total: 11500.0
- Compound Interest should be approximately 1576.25, Total: 11576.25


.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)