In [10]:

```
# given data
P=2000 # in rs
i=12 # interest rate in %
n=6 # time in years
F=P*(1+i/100.0)**n # Future value of investment
print "The amount will be Rs",round(F)
```

In [6]:

```
import math
# given data
P=10.0 # in lakh rs
i=12.25 # interest rate in %
F=20 # final amount in lakh rs
n=math.log(F/P)/math.log(1+i/100.0) # time in years
print "The number of years is ",round(n),"years"
```

In [11]:

```
#given data
F=100000 # final amount in rs
i=6 # interest rate in %
n=10 # time in years
P=F*(1/(1+i/100.0)**n) # initial amount
print "The initial value is Rs",round(P),
```

In [15]:

```
#given data
A=500 # annual amount invested each year in rs
i=9 # interest rate in %
n=6 # time in years
F=A*(((1+i/100.0)**n)-1)/(i/100.0) # future amount in rs
print "The Future amount will be Rs",round(F)
```

In [17]:

```
#given data
F=12000 # Total amount in rs
i=9 # interest rate in %
n=4 # time in years
A=F*(i/100.0)/(((1+i/100.0)**n)-1) #
print "The amount deposited each year should be Rs",int(A)
```

In [26]:

```
#given data
A=30000.0 # amount save each year in rs
i=10/100.0 # interest rate
n=8 # time in years
P=A*(((1+i)**n)-1)/(i*((1+i)**n)) # amount spent on replacement in rs
print "Amount spent on replacement is Rs",int(P)
```

In [41]:

```
#given data
i=12/100.0 # interest rate
n=10 # time in years
time=100.0 # days geyser is used in year
effi=0.9 # efficiency of geyser
w=100.0 # weight of water in kg
C=4.2 # heat capacity in kJ/kg-degree C
theta=60-15 # temperature difference in C
cost=4 # cost of electricity per kWh
Elec=(1/effi)*w*C*theta/3600.0 # electricity used in kWh/day
Elec=round(Elec,2)
A=Elec*time*cost # annual saving in Rs
P=A*(((1+i)**n)-1)/(i*((1+i)**n)) # final amount in rs
print "The final amount after 10 years is Rs",int(P)
```

In [48]:

```
# given data
P=200000.0 #principal value in rs
i=10/100.0 # interest rate
n=25.0 # time in years
L=2.0 # power produced in kW
A=P*(i*(1+i)**n)/(-1+(1+i)**n) # annualised capital cost in rs
maintcost=P*0.05 # annual maintainence cost
Totalcost=A+maintcost # total annual cost
Elec=L*0.25*10*365 # annual electricity production
Cost=Totalcost/Elec # unit cost of electricity production
print "unit cost of electricity production is Rs",round(Cost,1)
```

In [54]:

```
# given data
G=1 #gradient per period in lakh rs
i=12/100.0 # discount rate
n=5 # time in years
A1=10 # payment at end of 1st year in lakhs rs
loan=40 # load applied for in lakhs
AGin=(1/i)-5*1/(-1+(1+i)**n) # gradient to uniform series conversion factor
Ag=A1+G*AGin # in lakhs Rs
Pg=Ag*(-1+(1+i)**n)/(i*(1+i)**n) # present worth in lakhs rs
print "The present worth is Rs",round(Pg,2),"Lakh"
if (Pg*0.85<loan):
print "Loan is not given as amount is less than applied for loan"
else:
print "Loan is given"
```

In [58]:

```
# given data
g=0.2 # annual gas price increase rate
i=10/100.0 # discount rate
n=15 # time in years
A1=350*8 # payment at end of 1st year in lakhs rs
Pgg=(A1/(i-g))*(1-((1+g)/(1+i))**n) # present worth in Rs
print "The present worth of saving is Rs",round(Pgg)
```

In [64]:

```
# given data
Co=10000 # initial investment in rs
B=900.0 # net annual savings per year
nsp=Co/B # simple payback period
print "The simple payback period is ",round(nsp,2)
if nsp<20:
print "proposal may be accepted"
else:
print "proposal may not be accepted"
```

In [42]:

```
# given data
import numpy
ProjectA=[-2400,600,600,600,600,600]
ProjectB=[-2400,800,800,800,800,800]
ProjectC=[-2400,500,700,900,1100,1300]
ProjAcu=numpy.zeros(6) # cumulative cash flow for project A
for i in range(0,6):
ProjAcu[i]=ProjectA[i]+ProjAcu[i-1]
ProjBcu=numpy.zeros(6) # cumulative cash flow for project B
for i in range(0,6):
ProjBcu[i]=ProjectB[i]+ProjBcu[i-1]
ProjCcu=numpy.zeros(6) # cumulative cash flow for project C
for i in range(0,6):
ProjCcu[i]=ProjectC[i]+ProjCcu[i-1]
print "\t \t \t Project A \t \t \t \t \t \t \t \t \t Project B \t \t \t \t \t \t \t \t \t Project C"
print "year\t \t current \t cummulative \t \t \t \t \t current \t cummulative \t \t \t \t \t \t \t \t current \t \t cummulative \t"
for i in range(0,6):
print (i+1),"\t \t ",ProjectA[i],"\t \t \t \t ",ProjAcu[i]," \t \t \t \t \t \t ",ProjectB[i]," \t ",ProjBcu[i],"\t \t \t \t \t \t \t \t \t",ProjectC[i]," \t ",ProjCcu[i]," \t"
for i in range(0,6):
if ProjAcu[i]==0:
PA=i
for i in range(0,6):
if ProjBcu[i]==0:
PB=i
for i in range(0,6):
if (ProjCcu[i]<0 and ProjCcu[i+1]>0):
PC=(i)-ProjCcu[i]/ProjectC[i+1]
print " The payback period for project 1 is ",PA,"\n The payback period for project 2 is",PB,"\n The payback period for project 3 is ",round(PC,2)
```

In [48]:

```
# given data
import numpy
ProjAcu=[-2400.0,-1864.0,-1386.0,-959.0,-578.0,-238.0] # in Rs
ProjBcu=[-2400,-1686,-1048,-479.0,30,484] # in Rs
ProjCcu=[-2400,-1954,-1396,-755,-56.0,683] # in Rs
ProjAdis=[-2400,536,478,427,381,340] # in Rs
ProjBdis=[-2400,714,638,569,509.0,454] # in Rs
ProjCdis=[-2400,446,558,641,699,738.0] # in Rs
PA=0
PB=0
PC=0
for i in range(0,5):
if (ProjAcu[i]<0 and ProjAcu[i+1]>0):
PA=(i+1)-ProjAcu[i]/ProjAdis[i+1]
print "For project A"
if (PA==0):
print "Net loss, Thus should be rejected"
else:
print PA,"years is payback period"
for i in range(0,5):
if (ProjBcu[i]<0 and ProjBcu[i+1]>0):
PB=(i)-ProjBcu[i]/ProjBdis[i+1]
print "For project B"
if (PB==0):
print "Net loss, Thus should be rejected"
else:
print round(PB,2),"years is payback period"
for i in range(0,5):
if (ProjCcu[i]<0 and ProjCcu[i+1]>0):
PC=(i)-ProjCcu[i]/ProjCdis[i+1]
print "For project C"
if (PC==0):
print "Net loss, Thus should be rejected"
else:
print round(PC,2),"years is payback period"
```

In [27]:

```
# given data
import numpy
i=12.0/100 # interest rate
n=5.0 # years
ProjectA=[-2400,600,600,600,600,600]
ProjectB=[-2400,800,800,800,800,800]
ProjectC=[-2400,500,700,900,1100,1300]
NPVA=ProjectA[0]+ProjectA[1]*(((1+i)**n) - 1)/(i*(1+i)**n)
print "NPV of Project A is ",round(NPVA)
NPVB=ProjectB[0]+ProjectB[1]*(((1+i)**n) - 1)/(i*(1+i)**n)
print "NPV of Project B is ",round(NPVB)
ProjectNPVc=0 # cumulative cash flow for project A
for i in range(0,5):
ProjectNPVc=ProjectNPVc+(-ProjectC[0]+ProjectC[i])/(1+i)**(i+1)
print "NPV of Project C is ",round(ProjectNPVc)
# The answer for project C is wrong in the book
```

In [79]:

```
# given data
import numpy
Co=20000.0 # cost in Rs
B=3000.0 # annual benefit in rs
n=15.0 # time in years
i=15.0/100 # initial guess for rate
NPV=numpy.zeros(4)
NPV[0]=B*(((1+i)**n)-1)/(i*(1+i)**n)-Co
x=0
print "Iteration no. \t\t\t i* \t \t \t \t \t\t\t NPV(i*)"
while NPV[x]<0:
x=x+1
i=i-0.01
NPV[x]=B*(((1+i)**n)-1)/(i*(1+i)**n)-Co
for z in range(0,4):
print z+1," \t \t \t \t \t \t \t ",0.15-(z/100.0)," \t \t \t\t \t ",round(NPV[z])
IRR=i+(i+0.01-i)/(NPV[x]+NPV[x-1]) # using equation 14.28
print "The IRR is", round(IRR*100,1)
# the answer is slightly different in textbook due to approximation
```

In [1]:

```
# given data
i=12.0/100 # interest rate
ProjAdisB=[0,536.0,478,427,381,340] # discounted benefit for A
ProjAdisC=[2400.0,0,0,0,0,0] # discounted cost for A
ProjBdisB=[0,714.0,638,569,509,454] # discounted benefit for B
ProjBdisC=[2400.0,0,0,0,0,0] # discounted cost for B
ProjCdisB=[0,446.0,558,641,699,738] # discounted benefit for C
ProjCdisC=[2400.0,0,0,0,0,0] # discounted cost for C
BCforA=sum(ProjAdisB)/sum(ProjAdisC) # B mius C ratio
BCforB=sum(ProjBdisB)/sum(ProjBdisC) # B mius C ratio
BCforC=sum(ProjCdisB)/sum(ProjCdisC) # B mius C ratio
print "B - C for project A is ",round(BCforA,1)
print "B - C for project B is ",round(BCforB,1)
print "B - C for project C is ",round(BCforC,2)
```

In [95]:

```
# given data
Co=12000.0 # cost in Rs
Ca=200.0 # annual maintainence in Rs
C12=3000.0 # replacement cost in 12th year
S=1000.0 # salvage value in rs
n=20.0 # time in years
i=11/100.0 # interest rate
Cnet=Co-S*(1/(1+i)**n)+Ca*((((1+i)**n)-1)/(i*(i+1)**n))+C12*(1/(1+i)**12)
CR=Cnet*(i*(1+i)**n)/(((1+i)**n)-1)
print "The Capital Recovery cost is Rs",round(CR)
```

In [108]:

```
# given data
i=10/100.0 # rate
Acost=90000 # cost of A in Rs
Bcost=75000 # cost of B in Rs
Acashfl=26000 # annual cash flow of A in Rs
Bcashfl=26000 # annual cash flow of B in Rs
nA=5 # useful life of A in years
nB=4 # useful life of B in years
NPVA=Acashfl*(((1+i)**nA) - 1)/(i*(1+i)**nA) - Acost # NPV for A
NPVB=Bcashfl*(((1+i)**nB) - 1)/(i*(1+i)**nB)- Bcost # NPV for B
print "The NPV for A is ",round(NPVA)
print "The NPV for B is ",round(NPVB)
AEA=i*NPVA/(1-(1+i)**(-nA))
AEB=i*NPVB/(1-(1+i)**(-nB))
print "The AE for A is Rs ",int(AEA)
print "The AE for B is Rs ",int(AEB)
print "The machine B will have higher profitability"
```

In [135]:

```
# given data
import numpy
Co=120000.0 # cost in Rs
N=5 # useful life
T=40/100.0 # tax rate
i=9/100.0 # interest rate
Earning=[33000.0,35000.0,37000.0,39000,41000.0]
Depreciate=Co/N # depreciation in Rs
pretax=numpy.zeros(5)
discshfl=numpy.zeros(5)
for x in range(0,5):
pretax=Earning[x]-Depreciate
tax=0.4*pretax
ernng=pretax-0.4*pretax
cashf=ernng+Depreciate
discshfl[x]=cashf/(1+i)**(x+1)
netdiscntincm=sum(discshfl) # net discount income in Rs
NPV=netdiscntincm-Co # NPV
print "NPV of dryer is Rs",int(NPV)
# The answer in the book is wrong as the value of discounted cashflow is incorrect
```

In [137]:

```
# given data
Co=300000 # cost in Rs
S=20000.0 # salvage value in Rs
N=15 # useful life
D=(Co-S)/N # Depreciation
BV=Co # Book Value
for i in range(0,N):
BV=BV-D;
print "The Book value at the end of ",i+1,"th year is Rs",round(BV)
```