def npvTable(self,*args):
        """Compute the NPV and IRR values of a project with two different rates"""
        
        try:
            #You need at least one rate to compute an NPV
            assert self.r_1 !=0,"The first rate should not be equal to zero "

            res_1 = []
            res_2 = []
            item_1 =[]
            item_2 =[]
            count_1 = -1
        
            for arg in args:
     	
                count_1 +=1

                #outflows/inflows starting at year 0                 
                pv_set = PresentValue(r_1=self.r_1,r_2=self.r_2,n = count_1)
                res_1.append(pv_set.DF[0]) # Trigger the Discount factor at rate r_1 and append the res_1
                res_2.append(pv_set.DF[1]) # Trigger the Discount factor at rate r_2 and append the res_2            
            print "\n years \tCash flows \t DF at %s\t PV" %(str(int(self.r_1*100))+'%')

            count_2 = -1

            for (x_1,y) in (itertools.izip(res_1,args)):    #for loop return PV set item_1
                item_1.append((float(x_1)*y))

                count_2  +=1
            
                print "\n  %s\t%s\t\t %s\t\t%s" %(count_2,y,x_1,int(float(x_1)*y))

                npv_1 =(reduce(operator.add,item_1))    #Compute the npv_1 total
            
            print '\n\t\t\t\t NPV =  %s\n' % int(npv_1)
        
            if self.r_2 == 0:   #user attempt only one NPV calculation 
            
                print "<No NPV calculation %s=%s" % pv_set._asdict().items()[1]

            else:
            
                print "\n years \tCash flows \t DF at %s\t PV" %(str(int(self.r_2*100))+'%')

                count_3 = -1
            
                for (x_2,y) in (itertools.izip(res_2,args)):    #for loop return PV set item_2
                    item_2.append((float(x_2)*y))
                    count_3 +=1
                
                    print "\n  %s\t%s\t\t %s\t\t%s" %(count_3,y,x_2,int(float(x_2)*y))

                    npv_2 = (reduce(operator.add,item_2))   #Compute the npv_2 total 
                
                print '\n\t\t\t\t NPV =  %s\n ' % int(npv_2)

                #The IRR computation will depend of the rates and npvs (higher and lower values)               
                if self.r_1 > self.r_2:
                
                    print "<The IRR = %2.1f" % ((self.r_2+(npv_2/(npv_2-npv_1))*(self.r_1-self.r_2))*100)+' %\n'

                else:
                
                    print "<The IRR = %2.1f" % ((self.r_1+(npv_1/(npv_1-npv_2))*(self.r_2-self.r_1))*100)+' %\n'       
                print "<The project will be recommended on finanacial grounds, while "
                print "ignoring risk, if the IRR is greater than the target rate of "
                print "return, otherwise the project will be rejected.\n"

        #npvTable raises Negative number error
        except MinusSignError,exception:
            print exception
Compute the NPV and IRR values of a project with two different rates
recipes/Python/576683_IRRVersusNPV_26/recipe-576683.py