Compound Interest Calculator
Beginner · Write the code · from Python Numbers: Integers, Floats, and Math You'll Actually Use
From the lesson: Python Numbers: Integers, Floats, and Math You'll Actually Use
You're splitting a restaurant bill with three friends. The total is $85. How much does each person owe? You grab your phone calculator, but a Python programmer just types 85 / 4 and gets the answer instantly.
Read the lessonCalculate compound interest using this formula:
**A = P * (1 + r) t
Where:
Calculate the final amount and the interest earned, then print:
Final amount: $1628.89
Interest earned: $628.89Round both values to 2 decimal places.
principal = 1000
rate = 0.05
years = 10
# Calculate the final amount using the formula
# Calculate interest earned (final - principal)
# Print the results
More Numbers exercises
- Calculate the Total CostBeginner
- Even or Odd CheckerBeginner
- Fix the Bug: Wrong DivisionBeginner
- Fahrenheit to Celsius ConverterBeginner
- Predict the OutputBeginner
All Python exercises · 50 practice problems · Python Fundamentals quiz