How to create a simple Compound Interest Calculator

Created with Python
By :Julien Saindon
July 10, 2024



Here’s what you’ll see:
  1. What is compound Interest and how to calculate it.
  2. How to get started with Python.
  3. What the code means.
  4. Output.
  5. Conclusion.

1. What is compound Interest and how to calculate it?


SIMPLE INTEREST
To understand what Compound Interest is, we must understand what simple interest is. Simple interest is interest calculated on the original principal amount (i.e. the original amount of money you deposited in the account).
For example: if you deposited 5,000$ with a simple interest rate of 5% yearly, and left it there for 3 years, then at the end of the 3 years, you would make 750$ in interest alone!
So, your investment would grow to: 5000$ + 250$ + 250$ +250$ = 5,750$

COMPOUND INTEREST
With compound interest, you gain interest on the interest you made each time! Using the same example above, but now with Compounding Interest, your investment would now be: $5,788.13 Here’s a breakdown:
Year 1: you make 5% on $5,000 which is $250.
Year 2: you make 5% on $5,000 PLUS the 250$, so you actually make 5% on $5,250 which is $262
Year 3: you make $5,000 plus the interest on the interest you made in year 1 and 2: $275.
Total investment: $5,000 + $250 + $262 + $275 = approximately $5,788

The difference between is not much but, if left over for long periods of time, this amount can become exponential!

Here’s a better example with larger amounts:
Example : $50,000 invested with 8% simple interest (yearly) for 30 years : you will have a total investment of $170,000.00
Example 2: $50,000 invested with 8% compound interest (yearly) for 30 years: you will have a total investment of $503,132.84

That’s a difference of $283,132!!!

Below is the equation used to calculate compound interest rates:

2. How to get started with Python.

Depending on what system you are using (i.e. Linux, windows, MAC), navigate to this page Python and find your “get started guide” on how to use python in your favorite IDE.

3. What the code means.

In my example I will be using Windows and VS code to complete the project.

4. Results:


5. Conclusion:

The above is a very simple code that does not take into account inflation or variations in interest rates. Nor does it do any error handling. I realize there are better ways to write this code with fewer lines, but this is only an example of a simple code, and to show the importance of investing.

Notes:
www.python.org
https://www.pexels.com/
Wiki