Compound Interest Calculator
Calculate compound interest.
IntermediatePhase 6 - Category 5: Real-World Logic ProblemsExample 5 of 15
compound-interest-calculator.py
1# Take inputs2principal = float(input("Enter principal: "))3rate = float(input("Enter rate (%): "))4time = float(input("Enter time (years): "))5compounds = int(input("Enter compounds per year: "))67# Calculate8amount = principal * (1 + rate / (100 * compounds)) ** (compounds * time)9interest = amount - principal1011print(f"Compound Interest: {interest:.2f}")12print(f"Total Amount: {amount:.2f}")
Output
Enter principal: 10000 Enter rate (%): 5 Enter time (years): 2 Enter compounds per year: 12 Compound Interest: 1048.18 Total Amount: 11048.18
What's going on
Calculate compound interest using formula.
Key Concepts:
A = P * (1 + r/n)^(n*t)
CI = A - P
Compound interest formula
🔗Related Content
- 📖
Phase 6 - Learn Concepts
Review Phase 6 concepts and explanations
- 📝
Phase 6 - Quiz
Test your Phase 6 understanding with quiz questions
- 💻
Phase 6 - All Practice Problems
Explore all practice problems for Phase 6
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum