**Our program.** The compound_interest method computes the total value of the money (principal) after interest is paid. We specify the rate (the interest rate, expressed as a percentage).

**Rate:** This is the interest rate. For an interest rate of 4.3%, we can pass 0.043.

**Times:** The times_per_year argument indicates yearly (1), quarterly (4) or monthly (12) interest.

**Years:** This final argument to compound_interest tells us how many years we compound interest. Thinking long-term is important.

**Python program that computes compound interest**
def __compound_interest__(principal, rate, times_per_year, years):*
# (1 + r/n)
*body = 1 + (rate / times_per_year)*
# nt
*exponent = times_per_year * years*
# P(1 + r/n)^nt
*return principal * pow(body, exponent)*
# Compute 0.43% quarterly compound interest for 6 years.
*result = compound_interest(1500, 0.043, 4, 6)*
# Write result.
*print(result)
print()*
# Compute 20% compound interest yearly, quarterly and monthly.
*print(compound_interest(1000, 0.2, 1, 10))
print(compound_interest(1000, 0.2, 4, 10))
print(compound_interest(1000, 0.2, 12, 10))
**Output**
1938.8368221341054
6191.7364223999975
7039.988712124658
7268.254992160187

**Yearly, quarterly, monthly.** In the last three calls to compound_interest above, we compare how the final amount of money changes based on how often interest is paid.

**And:** Monthly and quarterly interest accumulates much faster than yearly interest. So this metric is important in an investment.

**Tip:** This comparison can help us judge certain investments. For example, bonds may pay monthly, but dividend stocks quarterly.