[Tutor] Hooked on innumeracy....
kromag@nsacom.net
kromag@nsacom.net
Tue, 17 Jul 2001 14:05:09 -0700 (PDT)
I have been attempting to make a little amortization calculator:
-----------------begin mort--------------------
def mort(cash,interest, payment):
count=1
bait=cash #retain the original amount for final calucation of total
interest.
screwing=interest/12
interest=screwing+1
try:
while cash > payment:
cash= cash * interest
cash = cash - payment
count=count +1
finally:
ouch=payment * count + cash # number of payments * payment
amount + remainder
print `count` + ' payments of ' + `payment` + ' each.'
print 'Plus one payment of ' + `cash`
print `ouch -bait ` + ' total screwing.'
-------------------end mort---------------------
Now I don't have any idea if my math is right here. It seems logical to me,
but then, I majored in english and drama.
I get the following weirdness when I attempt to use it:
---------------begin weirdnesss------------------
>>> from kersplort import mort
>>> mort(4000,0.07,250.00)
17 payments of 250.0 each.
Plus one payment of 210.26436268423424
460.26436268423458 total screwing.
>>> mort(4000,0.07,350.00)
12 payments of 350.0 each.
Plus one payment of 300.00544031562856
500.00544031562822 total screwing.
>>> mort(4000,0.07,150.00)
30 payments of 150.0 each.
Plus one payment of 10.313364085220485
510.3133640852202 total screwing.
>>>
---------------end weirdness---------------------
You'll note that the amount of screwing (total interest payments) seems to be
nonlinear with the payment amount. What am I missing here? I fully admit to
being an arithmetic moron, so flame away! :-)