Contact Us!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download
Views: 127
Image: ubuntu2004
Kernel: Python 3 (system-wide)
Suppose you start a savings account with $1400. The account pays a 3.4% annual interest compounded monthly. You make monthly contributions of $50 per month for 2 years. After those two years, you are able to contribute $60 per month from that point on. How much is the account worth 5 years after you first started it?
def com_int(p,r,n,c,y): for i in range (n*y): p = p*(1+r/n)+c return p
com_int(1400,0.034,12,50,2) # Inpur 50 for c since we contribute $50 each months with principal $1400 for 2 years.
2738.291988214431

After that, out task wants us to find the total of this account if we contribute $60 instead of 50 after 3 years (5 years in total)

com_int_after2 = com_int(1400,0.034,12,50,2)
com_int(com_int_after2,0.034,12,60,3) #For this, we input our principal amount(p), which we got after 2 years, and change the monthly contributions(c) to $60 for 3 years.
5302.522941212652

Thus, we got the total amount of $5302.52 on savings account after 5 years of different monthly contributions