How to Calculate NPV?

duncan smith buzzard at invalid.invalid
Wed Jul 29 12:14:40 EDT 2015


On 29/07/15 15:27, ryguy7272 wrote:
> On Wednesday, July 29, 2015 at 10:21:35 AM UTC-4, ryguy7272 wrote:
>> On Wednesday, July 29, 2015 at 9:59:10 AM UTC-4, ryguy7272 wrote:
>>> I am using Spyder Python 2.7.  I'm running this sample code.
>>>
>>> import scipy as sp
>>> cashflows=[50,40,20,10,50]
>>> npv=sp.npv(0.1,cashflows)
>>> round(npv,2)
>>>
>>>
>>> Now, I'm trying to get the NPV, and I don't see any obvious way to get it.  
>>> The author of the book that I'm reading gets 144.56.  I think that's wrong, but I don't know for sure, as Python won't do any calculation at all.  It's easy to enter code and run it, but I can't tell how to get Python to actually DO the calculation.
>>>
>>> Any idea what I'm doing wrong?
>>  
>> PERFECT!!  SO SIMPLE!!
>> I don't know why the author didn't do that in the book.
>>
>> Thanks!
> 
> One last thing, for Excel users, leave out the initial CF.  Do the NPV on the other CFs, and then add in the initial CF at the end of the NPV function.  It's almost like a PV + 1stCF.  I don't know why Excel does it like that...
> 

I don't know what Excel does, but the first value shouldn't require any
special treatment, 1.1**0 = 1.

>>> sum([x/(1.1)**i for i, x in enumerate([50,40,20,10,50])])
144.55638276074038
>>>

Duncan



More information about the Python-list mailing list