Introduction
Compound Interest¶
When you store money at a bank, you can expect that each year you will gain a percent of your holdings as interest. These holdings, however, include any interest earned up until this point which means you earn interest on your interest. This is the idea of compound interest; you will earn more in interest each year as your holdings increase. To illustrate this point, let’s work through an example year by year. Say you start with \$100 in a bank account which gives you an annual rate of 5%. The principal at time 0 is \\$100 which earns 5% interest meaning the principal in time 1 will now be \$150.
In [1]:
p = 100
print("The starting principal is ${}".format(p))
interest = p * .05
print("The interest earned is: ${}".format(interest))
p = p + interest
print("The ending principal is ${}".format(p))
Now, the next year we make interest on the $105.
In [2]:
print("The starting principal is ${}".format(p))
interest = p * .05
print("The interest earned is: ${}".format(interest))
p = p + interest
print("The ending principal is ${}".format(p))
Let's formalize this into a loop to see the effect over the next couple of years.
In [3]:
p = 100
r = .05
for t in range(1,6):
print("----Year {}----".format(t))
print("Starting Principal: ${}".format(p))
interest = p * .05
print("Interest Earned: ${}".format(interest))
p = p + interest
print("Ending Principal: ${}".format(p))
print("---------------")
print()
print()