Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

All published worksheets from http://sagenb.org

189956 views
ubuntu2004
def amortization(loan, terms, rate): print "Balance".center(15) + \ "Payment".center(15) + \ "Principal_Paid".center(15) + \ "Interest_Paid".center(15) A = (loan * rate) / (1 - pow(1 + rate, -terms)) for i in xrange(terms): P = loan * pow(1 + rate, i) - A * (pow(1 + rate, i) - 1) / rate R = P * rate print str(round(P, 2)).center(15) + \ str(round(A, 2)).center(15) + \ str(round(A - R, 2)).center(15) + \ str(round(R, 2)).center(15) amortization(100, 10, 0.5)
Balance Payment Principal_Paid Interest_Paid 100.0 50.88 0.88 50.0 99.12 50.88 1.32 49.56 97.79 50.88 1.99 48.9 95.81 50.88 2.98 47.9 92.83 50.88 4.47 46.42 88.36 50.88 6.7 44.18 81.66 50.88 10.05 40.83 71.61 50.88 15.08 35.81 56.54 50.88 22.61 28.27 33.92 50.88 33.92 16.96