-3

So I have this cash flow given: time= [0,1,2,3,4,5]cf = [100,25,-30,4,-12,60] and say that the pay period is semiannually and the compounding period is is years.

So I need to have the cash flow add the terms ([100+25,-30+4,-12,60]) in order to calculate the irr and npv from the modified cash flow: [125, -26, 48]

Any thoughts on how to do this?

4

1 回答 1

0

您可以使用简单的列表推导来对每组n值求和;

>>> cf = [100,25,-30,4,-12,60]
>>> n = 2
>>> [sum(cf[x:x+n]) for x in range(0, len(cf), n)]
[125, -26, 48]
于 2013-10-10T19:18:04.040 回答