Understanding Simple vs Compound Interest Logic

Day 3/30 Comparing options is easy… but choosing the better one requires understanding the logic behind it. 🔹 Problem: Compare Simple Interest and Compound Interest 🔹 What I focused on today: Understanding the difference in calculation logic between simple and compound interest 🔹 My Thinking Process: Simple Interest is calculated only on the principal amount Compound Interest is calculated on principal + accumulated interest Compare both results to see how compounding makes a difference 👉 Even small changes in logic can lead to big differences in output 🔹 Inputs I used: Principal amount Rate of interest Time (in years) 🔹 Code: principal = float(input("Enter principal amount: ")) rate = float(input("Enter rate of interest: ")) time = float(input("Enter time (in years): ")) # Simple Interest simple_interest = (principal * rate * time) / 100 # Compound Interest amount = principal * (1 + rate / 100) ** time compound_interest = amount - principal print("Simple Interest:", simple_interest) print("Compound Interest:", compound_interest) 🔹 Example: Principal = 1000, Rate = 10%, Time = 2 years Simple Interest = 200 Compound Interest = 210 🔹 Key Takeaway: Compound interest grows faster because it builds on previous interest, not just the original amount #Day3 #Python #30DaysOfCode #LearningInPublic #DataAnalytics #ProblemSolving

To view or add a comment, sign in

Explore content categories