In [1]:

```
from __future__ import division
Co = 250000 # original value of machine tool in Rs
Cs = 25000 # salvage value in Rs
n = 20 #useful life in years
d = (Co-Cs)/n # depreciation per year in Rs
v1 = Co - 10*d # value of machine tool at the end of 10 years in Rs
s = Co - Cs # sum at the end of useful life in Rs
i = 8/100 # annual interst rate
D = (s*i)/((1 + i)**n-1) # annual deposit
a = D*((1+i)**10-1)/i #amount at the end of 10 years in Rs
v2 = Co - a # value at the end of 10 years
print "Value of machine at the end of 10 years through straight line depreciation method = Rs %d"%(v1)
print "Value of machine at the end of 10 years through sinking fund method = Rs %d"%(v2)
# Answers vary due to round off error
```

In [2]:

```
p = 200000 # present worth in Rs
i = 10 # annual interest rate
i = 10/100
n = 20 # number of years
a1 = (p*i)/((1+i)**n-1) # annual investment using sinking fund factor in Rs
a2 = (p*i*(i+1)**n)/((i+1)**n-1)# annual investment using capital recovery factor in Rs
print "Annual investment using sinking fund factor = Rs %d /- per year"%(a1)
print "Annual investment using capital recovery factor = Rs %d /- per year"%(a2)
# Answers vary due to round off error
```

In [3]:

```
# cash in flows
a = 21240 # annual revenue in Rs
i = 10 # annual interest rate
i = 10/100
n = 5 # perod in years
f1 = 8000 # salvage value in Rs
p1 = (a*((i+1)**n-1))/(i*(i+1)**5)# annual revenue in Rs
p2 = f1/(i+1)**5 #present worth in Rs
t1 = p1 + p2 # total cash in flows in Rs
# cash out flows
I = 40000 # investment in Rs
f2 = 12000 # annual payment in Rs
p3 = (f2*((1+i)**5-1))/(i*(1+i)**5) # annual payments in Rs
t2 = I + p3 # total cash out flows in Rs
print "Total cash in flows = Rs %0.2f\nTotal cash out flows = Rs %0.2f"%(t1 ,t2)
print "Since cash out flows are more than cash in flows therefore project is not economical"
# Answers vary due to round off error
```

In [4]:

```
#Machine A
f1 = 2000 # annual benefit from better production quality in Rs
i = 10 # interest rate
i = 10/100
f2 = 12000 # salvage value in Rs
f3 = 8000 # operating and maintenance cost in Rs
I1 = 100000 # initial cost in Rs
n = 5 # years
p1 = (f1*((1+i)**n-1))/(i*(i+1)**n)
p2 = f2/(1+i)**n
c1 = p1 + p2 # cash in flows in Rs
p3 = (f3*((1+i)**n-1))/(i*(i+1)**n)
c2 = I1 + p3 # cash out flows in Rs
Pa = c1 - c2 # net P.W.in Rs
#Machine B
I2 = 60000 # initial cost in Rs
f4 = 16000 # operating and maintenance cost in Rs
f5 = 14000 # reconditioning at the end of third year in Rs
p4 = (16000*((1+i)**5-1))/(i*(1+i)**5)
p5 = f5/(1+i)**5
Pb = -I2 - p4 - p5 # net P.W.in Rs
print " Net P.W.of Machine A= Rs %0.2f\n Net P.W.of Machine B = Rs%0.2f"%(Pa ,Pb)
print " It is clear that Net P.W of Machine A is less nagative as compared to that of Machine B , therefore Machine A is economcal."
# Answers vary due to round off erro
```

In [5]:

```
#machine A
c1 = 20000 # manual cost in Rs
c2 = 40000 # operating cost in Rs
n1 = 2 # machine life in years
i = 10 # interest rate
i = 10/100
crf1 = ((1+i)**n1-1)/(i*(i+1)**n1) # capital recovery factor
pw1 = c1+c2*crf1 # present worth in Rs
# machine B
c3 = 50000 # manual cost in Rs
c4 = 30000 # operating cost in Rs
n2 = 4 # machine life in years
i = 10/100 # interest rate
crf2 = ((1+i)**n2-1)/(i*(i+1)**n2) # capital recovery factor
pw2 = c3+c4*crf2 # present worth in Rs for 4 years
pw3 = (pw2*crf1)/crf2 # present worth in Rs for 2 years
print " P.W. of expenses for A = Rs %d\n P.W. of expenses for B = Rs %0.2f" %(pw1,pw3)
print " As the expenses of machine B are less , so this is economical"
# Answers vary due to round off error
```

In [6]:

```
#Machine A
i = 8 # # interest rate
i = i/100 # interest rate
n1 = 10 # economic life in years
CRF1 = i*(1+0.08)**n1/((1+i)**n1-1) # capital recovery factor
p1 = 46000 # first cost in Rs
s1 = 8000 # salvage value in Rs
o1 = 10000 # operating charges in Rs
AC1 = (p1-s1)*CRF1 + s1*i + o1 # annual cost in Rs
#Machine B
n2 = 15 # economic life in years
CRF2 = i*(1+0.08)**n2/((1+i)**n2-1) # capital recovery factor
p2 = 60000 # first cost in Rs
s2 = 10000 # salvage value in Rs
o2 = 9200 # operating charges in Rs
AC2 = (p2-s2)*CRF2 + s2*i + o2 # annual cost in Rs
print " Annual cost of machine A = Rs %0.2f\n Annual cost of Machine B = Rs %0.2f" %(AC1, AC2 )
print " Machine B will be economical"
# Error in textbook
```

In [7]:

```
a = 100000 # Ej(p/f,e%,j) in Rs
n = 5 # life in years
e = 20 # M.A.R.R.
e = e/100 # M.A.R.R.
i = e
A = 32000 # savings in Rs
s = 20000 # salvage value in Rs
b = ((A*(((i+1)**n)-1)/i)+s)/a # (F/p,I,5)
i2 = (b)**(1/n)-1 # internal rate of return
print " ERR = %0.4f\n Internal rate of return = %0.2f percent"%(b , i2*100)
print " Since Internal rate of return is > M.A.R.R , therefore project is feasible"
```

In [8]:

```
e = 20 # M,A.R.R.
i = e # interest rste
i = i/100
n = 5 # life in years
s = 32000 # annual net savings in Rs
p = 100000 # present worth in Rs
S = 20000 # salvage value in Rs
a = (p-S)*(i/((1+i)**n-1)) # (p-s)(A/F,e%,n)
E = (s-a)/p # E.R.R.R
print "ERRR = %0.2f percent"%(E*100)
print "Since E.R.R.R is > M.A.R.R. therefore project is feasible."
```

In [9]:

```
# machine A
r_e1 = 9600 #cash flow in Rs
p1 = 46000 # intial cost in Rs
s = 0 # salvage value
e = 8 # M.A.R.R
e = e/100
i = 8 # investment rate
i = i/100
n = 6 # life in years
x = i/((1+i)**n-1)
ERRR1 = (r_e1 - (p1-s)*x)/p1
#machine B
r_e2 = 7200 #cash flow in Rs
p2 = 32000 # intial cost in Rs
ERRR2 = (r_e2 - (p2-s)*x)/p2
print " ERRR1 = %0.2f percent \n ERRR2 = %0.2f percent"%(ERRR1*100 ,ERRR2*100)
print " Only machine B is accepteble"
```

In [10]:

```
pmv = 15000 # present market value in Rs
ss = 6000 # sum needed to make it serviceable in Rs
ic = ss + pmv # investment cost in Rs
pbv = 30000 # present book value in Rs
sv = 15000 # salvage value in Rs
ui = pbv - sv # unamortized investment in Rs
print " Investment cost = Rs %d\n Unamortized investment = Rs %d"%(ic , ui)
```

In [11]:

```
# Existing machine
pmp = 100000 # present market price in Rs
io = 50000 # immediate overhauling in Rs
asl = 5 # additional service life in years
aoc = 50000 # annual operating cost in Rs
svo = 10000 # salvage value after overhauling in Rs
pc = io + pmp # present cost in Rs
i = 10 # interest rate
i = 10/100
crf1 = (i*(1+i)**asl)/((1+i)**asl - 1) # capital recovery factor
AC1 = (pc - svo)*crf1 + svo*i + aoc # average cost in Rs
# proposed machine
n = 10 # expected economic life in years
ic = 300000 # initial cost in Rs
sv = 100000 # salvage value in Rs
o = 30000 # annual operating cost in Rs
crf2 = (i*(1+i)**10)/((1+i)**10 - 1)
AC2 = (ic - sv)*crf2 + sv*i + o # average cost in Rs
print " Existing machine = Rs %0.3f \n Proposed machine = Rs %0.2f"%(AC1 , AC2)
print " Since the equivalent annual cost of proposed machine is less than that of the existing machine , therefore, the replacement is justified."
# Answers vary due to round off error
```

In [12]:

```
from math import sqrt
c = 20000 # first cost of machine in Rs
s = 1000 # scrap value in machine in Rs
b = 180 # annual increase in cost of repairs in Rs
n = sqrt(2*(c-s)/b) # years
print "Number of years of economic repair life = %0.2f years"%(n)
```

In [13]:

```
Cn = 72000 # cost of new machine installed and tooled in Rs
Co = 28000 # cost of new machime installed and tooled in Rs
p = 16 # hourly pieces
Nn = 2200*p # estimated annual production on new machine
Ko = 17200 # present book value of old machine in Rs
So = 6400 # scrap value of old machine in Rs
Sn = 8000 # probable scrap value of old machine in at the end of its useful life Rs
oco = 2.5 # opreator cost per hour
mco= 48 # machine cost
ro = 10 # production rate per hour
ocn = 2 # opreator cost per hour
mcn= 62 # machine cost
rn = 16 # production rate per hour
Po = (oco+mco)/ro # labour and machine cost per unit on old machine in Rs
Pn = (ocn+mcn)/rn # labour and machine cost per unit on new machine in Rs
i = 6 # interest on investment
i = i/100
t = 6 # annual taxes
t = t/100
d = 10 # annual allowance for depreciation
d = d/100
m = 3 # annual allowance for maintenance
m = m/100
n = ((Cn-Sn)+(Ko-So))/((Nn*(Po-Pn)) - Cn*(i+t+d+m))
print "The number of years in which the new machine will pay for itself = %0.3f years"%(n)
```

In [14]:

```
C = 80000 # cost of new machine installed and tooled in Rs
nel = 2 # number of engine lathes
c = 32000*nel # first cost of engine lathe
N = 4000 # annual production of turret lathe
n = 3800 # annual production in engine lathe
nhp1 = 4 # hp motor
L = 2256*nhp1 # annual labour cost of turret lathe
w = 5 # wage in per hour
time = 2300 # hours
l = time*nel*w # labour cost of engine lathe
nhp2 = 2.5 # hp motor
pr = 0.35 # power rate in kwh
p = (nel*nhp2*746*time*pr)/1000 # power cost
P = (nhp1*746*time*pr)/1000 # power cost
F = 480 #saving
I = 6/100 # interest rate
T = 4/100 # tax rate
D = 10/100 # allowance for depreciation in engine lathe
M = 6/100 # allowance for maintenance in engine lathe
B = 55/100 # labour burden in engine lathe
i = 6/100 # interest rate
t = 4/100 # tax rate
d = 10/100 # allowance for depreciation in turret lathe
m = 6/100 # allowance for maintenance in turret lathe
X = (L + B*L + P +C*(I+T+D+M) - F)/N
x = (l+l*B + p + c*(i+t+d+m))/n
print " Unit production cost on turret lathe = Rs %0.2f per piece\n Unit production cost on engine lathe = Rs %0.2f per piece"%(X , x)
print " Turret lathe will be more economical than two engine lathe"
# Answers vary due to round off error
```

In [15]:

```
X = 9.16 # production cost on turret lathe
N = 4000 # annual requirement
c = X*N # cost for 4000 pieces on turret lathe
n = 3800 # production of engine lathe
l = 23000 # labour cost
p = 3002 # power cost
i = 6 # interest rate
i = i/100
t = 4 # tax rate
t = t/100
d = 10 # allowance for depreciation in turret lathe
d = d/100
m = 6 # allowance for maintenance in turret lathe
m = m/100
b = 55/100 #labour burden
a = i+t+d+m
tc = 64000 # first cost of engine lathe
c1 =(N*(l*(1+b)+p))/n+(tc*a) # cost for engine lathe
s = c1-c # savings
amt = s/a # amount invested in turret lathe over the cost of engine lathe
print "Amount invested in turret lathe over the cost of engine lathe = Rs %d"%(amt)
# Answers vary due to round off error
```

In [16]:

```
Cn = 60000 # cost of new machine
Sn = 5000 # scrap value of new machine
So = 1000 # scrap value of old machine
Nn = 200000 #annual production
I = 10 # interest rate
I = I/100
M = 7 # allowance for maintenane
M = M/100
T = 6 # annual taxes
T = T/100
D = 1/10 # allowance for depreciation
lco = 300 # labour charges for old machine
m = 12 # months
rco = 15000 # running charges for old machine
pro = 50000 # production rate for old machine
lcn = 500 # labour charges for new machine
rcn = 10000 # running charges for old machine
prn = 200000# production rate f
Po = (lco*m + rco)/pro # labour and machine cost on old machine
Pn = (lcn*m + rcn)/prn # labour and machine cost on new machine
n =((Cn-Sn)-So)/((Nn*(Po-Pn))-Cn*(I+T+D+M)) #years
print "Years in which new machine will pay for itself = %0.2f years"%(n)
```

In [17]:

```
a = 1.50 #saving in labour
b=55/100 # burden applied on labour
T = 4/100 # allowance for taxes
M = 5/100 # allowance for maintenance
I = 8/100 # interest rate
D = 50/100 # allowance for depreciation
H = 2 # years to amortize the investment
S = 50 # yearly cost for set up
C = 3000 # first cost
N1 = (C*(I+T+M+D)+S)/(a*(1+b)) # annual production when 1 run is made
r = 5 # number of runs
N2 = (C*(I+T+M+D)+S*r)/(a*(1+b)) # annual production when 1 run is made
D1 = 100/100 # allowance for depreciation
N3 = (C*(I+T+M+D1)+S)/(a*(1+b)) # production when D = 100
n1 = 1530 # pieces
C1 = (n1*(a*(1+b))-S)/(I+T+M+D1) # economical investment
n2 = 950 # pieces
a1 = 2 # labour cost
r1 = 6 # number of runs
S1 = r1*S # yearly cost
V = n2*a1*(1+b)-C*(I+T+M+D)-S1 #profit
print "Number of pieces when one run is made and cost is Rs 3000 = %d pieces"%(N1)
print "Annual production when 5 runs are made per year = %d pieces"%(N2)
print "Annual production when fixture pay for itself = %d pieces"%(N3)
print "Economical investment when 1530 pieces for single run with savings Rs 1.50 per piece = Rs %d"%(C1)
print "Annual profit when 950 pieces made per year in 6 runs and saving in labour cost Rs 2 per piece = Rs %d per year"%(V)
# 'Answers vary due to round off error'
```

In [18]:

```
a = 0.125 #saving in labour cost per unit
b = 0.4 # overhead applied on direct labour saved
D = 1/2 # allowance for depreciation
C = 2400 # first cost
I = 6/100 # interest rate
T = 4/100 # allowance for taxes
M = 10/100 # allowance for maintenance
S = 80 # cost of set up
N = (C*(I+T+D+M)+S)/(a*(1+b)) # pieces per year
t = N*2 # total number of pieces
print "Total number of pieces produced = %d"%(t)
# Answers vary due to round off error
```

In [19]:

```
a = 0.125 # saving in labour cost per unit
b = 0.4 # overhead applied on direct labour saved
D = 1/2 # allowance for depreciation
C = 2400 # first cost
I = 6/100 # interst rate
T = 4/100 # allowance for taxes
M = 10/100 # allowance for maintenance
n = 6 # number of baches
S = 80 # cost of set up
s1 = S*n # total set up cost
N = (C*(I+T+D+M)+s1)/(a*(1+b)) # pieces
t = N*2 # total number of pieces
print "Total number of pieces produced = %d"%(t)
# Answers vary due to round off error
```

In [20]:

```
C1 = 2000 # first cost small tool in Rs
N = 5000 # parts per year
n = 5 # number of batches
S = 50*n # cost of set up
a = 0.15 # saving in labour cost per unit
b = 50/100 # burden applied on direct labour saved
I = 10/100 # interest rate
T = 5/100 # allowance for tax
M = 10/100 # allowance for maintenance
H = C1/((N*a*(1+b))-(C1*(I+T+M))-S) # years
C2 = 1600 # cost of fixture
D = 1/H # allowance for depreciation
V = N*a*(1+b)-C2*(I+T+D+M)-S # profit
print " Number of years taken by fixture of Rs 2000 = %0.2f years\n profit made when fixture of Rs 1600 = Rs %d"%(H ,V)
```

In [21]:

```
c1 = 3 # machine cost per component using existing euipment in Rs
c2 = 1 # machine cost using fixture in Rs
s = c1 - c2 # saving in machine cost per piece
f= 1000 # cost of fixture in Rs
N = f/2 # components
print "Minimum number of components to be produced if cost of fixture to be recovered = %d"%(N)
```

In [22]:

```
C = 1000 # cost of fixture
Co = 700 # cost of old fixture
Cs = 250 # scrap value
a = 10 #saving per piece in paisa
a = a/100
b = 30 # overhead applied on direct labour saved
b = b/100
I = 8 # interest rate
I = I/100
M = 3 # allowance for maintenance
M = M/100
T = 12 # allowance for tax
T = T/100
H = 3/2 # amortization
D = 1/H # allowance for depreciation
N = (C*(I+T+D+M)+(Co-Cs)*I)/(a*(1+b)) # pieces per year
print "Number of pieces which must be produced to break even so that fixture may pay for itself = %d pieces per year"%(N)
# Answers vary due to round off error
```

In [23]:

```
N = 9000 # number of pieces
Co = 700 # cost of old fixture
Cs = 250 # scrap value
a = 10 #saving per piece in paisa
a = a/100
b = 30 # overhead applied on direct labour saved
b = b/100
I = 8 # interest rate
I = I/100
M = 3 # allowance for maintenance
M = M/100
T = 12 # allowance for tax
T = T/100
H = 3/2 # amortization
D = 1/H # allowance for depreciation
C = (N*a*(1+b)-(Co-Cs)*I)/(I+T+D+M) # cost in Rs
print "Cost for new fixture = Rs %d"%(C)
# Answers vary due to round off error
```

In [24]:

```
n = 6500 # yearly production
c = 1350 # cost of fixture
a = 10 #saving per piece in paisa
a = a/100
b = 30 # overhead applied on direct labour saved
b = b/100
I = 8 # interest rate
I = I/100
M = 3 # allowance for maintenance
M = M/100
T = 12 # allowance for tax
T = T/100
co = 700 # cost of old fixture
cs = 250 # scrap value
H = (c)/((n*a*(1+b))-I*(co-cs)-c*(I+T+M)) # amotization in years
print "Time taken to amortize the fixture = %0.1f years"%(H)
```

In [25]:

```
n = 9000 # production of pieces per year
c = 1000 # fixture costs
Co = 700 # cost of old fixture
Cs = 250 # scrap value
a = 10 #saving per piece in paisa
a = a/100
b = 30 # overhead applied on direct labour saved
b = b/100
I = 8 # interest rate
I = I/100
M = 3 # allowance for maintenance
M = M/100
T = 12 # allowance for tax
T = T/100
h = 1.5 # amortization
D = 1/h # allowance for depreciation
V = (n*a*(1+b))-(c*(I+T+D+M))-((Co-Cs)*I) # profit
print "profit = Rs %d "%(V)
# Answers vary due to round off error
```

In [26]:

```
fc1 = 100000 # fixed cost in Rs
vc1 = 100 # variable cost in Rs per unit
sp = 200 # selling price in Rs per unit
q1 = fc1/(sp-vc1) # quantity of production at break even point
fc2 = 125000 # fixed cost in Rs
vc2 = 90 # variable cost in Rs per unit
q2 = fc2/(sp-vc2) # quantity of production at break even point
p = 20000 # profit in Rs
q3 = (fc1 + p)/(sp-vc1) # quantity of production at profit of Rs 20000
print " Break even point = %d pieces \n If fixed cost is 125000 and variable cost is Rs 90 per unit then break even point = %d pieces\n Number of components to get profit of Rs 20000 = %d pieces"%(q1 , q2 ,q3)
```

In [27]:

```
fc1 = 12000 # fixed cost for machine A in Rs
fc2 = 48000 # fixed cost for machine B in Rs
n1 = 6 # unit production cost in Rs per piece for machine A
n2 = 1.2 # unit production cost in Rs per piece for machine B
q = (fc2-fc1)/(n1-n2) # break even point
print "Break even point = %d pieces"%(q)
```

In [28]:

```
# capstan lathe
tc1 = 300 # total cost in Rs
mc1 = 2.5 # material cost per piece in Rs
olc1 = 5 # operation labour cost per hour in Rs
ct1 = 5 # cycle time per piece in min.
slc1 = 20 # setting up labour cost in Rs per hour
st1 = 1 # setting up time in hour
mo1 = 300/100 # machine over heads of operation labour cost
o1 = mo1*olc1 # overheads of capstan lathe in Rs per hour
fc1 = tc1 + slc1*st1 + o1*st1 # fixed cost of capstan lathe in Rs
vc1 = mc1 + (olc1*ct1)/60 + (o1*ct1)/60 # variable cost in Rs
# Automatic (single spindle)
tc2 = 300 # total cost in Rs
cc2 = 1500 # cost of cams in Rs
mc2 = 2.5 # material cost per piece in Rs
olc2 = 2 # operation labour cost per hour in Rs
ct2 = 1 # cycle time per piece in min.
slc2 = 20 # setting up labour cost in Rs per hour
st2 = 8 # setting up time in hour
mo2 = 1000/100 # machine over heads of operation labour cost
o2 = mo2*olc2 # overheads of single spindle in Rs per hour
fc2 = tc2 + cc2 + slc2*st2 + o2*st2 # fixed cost of single spindle in Rs
vc2 = mc2 + (olc2*ct2)/60 + (slc2)/60 # variable cost in Rs
q = (fc2-fc1)/(vc1-vc2) # break even quantity
print " Break even quantity for a component which can be produced on either the capstan lathe or single spindle automatic = %d pieces"%(q)
```

In [29]:

```
# Engine lathe
t = 12 # time/piece in min.
l = 7 # overhead cost/hr
o = 4 # direct labour cost/hr
s = 2 # set up time in hour
sr = 8 # set up rate per
# turret lathe
T = 5 # time/piece in min.
L = 5 # overhead cost/hr
O = 8 # direct labour cost/hr
S = 8 # set up time in hour
SR = 8 # set up rate per
q = 60*(S*SR-s*sr)/(t*(l+o)-T*(L+O)) # break even point
q = round(q)
print "Break even point = %d pieces"%(q)
```

In [30]:

```
from sympy import symbols, solve
fc1 = 80000 # fixed cost for turret lathe in Rs
fc2 = 32000 # fixed cost for engine lathe in Rs
n1 = 16 # production of pieces per year in turret lathe
n2 = 10 # production of pieces per year in engine lathe
vc1 = 2 #operators cost in turret lathe
vc2 = 2.5 # operators cost in engine lathe
Q=symbols('Q')
expr = (fc1+1/n1*vc1*Q)-(fc2+2.5*Q/10)
Q=solve(expr,Q)[0]
print "Break even point = %d pieces"%(Q)
```

In [31]:

```
st1 = 15 # set up time for engine lathe in min.
ut1 = 15 # unit time for engine lathe in min.
st2 = 90 # set up time for automatic lathe in min.
ut2 = 1.5 # unit time for engine lathe in min.
q = (st2-st1)/(ut1-ut2) # quantity of production
print "The point at which the automatic lathe will be justified = %0.2f "%(q)
# Answers vary due to round off error
```

In [32]:

```
# Automatic lathe
p = 30 # number of pieces produced per hour
l = 4 # labour rate per hour in Rs
d = 4.50 # hourly depreciation rate per machine in hour
s = 4 # set up time in hour
# turret lathe
P = 10 # number of pieces produced per hour
L = 4 # labour rate per hour in Rs
D = 1.50 # hourly depreciation rate per machine in hour
S = 2 # set up time in hour
q = (P*p*(S*L+S*D-s*l-s*d))/(P*(l+d)-p*(L+D)) # quantity of pieces at break even point
print "Quantity of pieces at Break even point = %d pieces"%(q)
```

In [33]:

```
Pa = 8.4 # unit tool process cost for method A in Rs
Pb = 14.8 # unit tool process cost for method B in Rs
Ta = 6480 #total tool cost for method A in Rs
Tb = 1616 #total tool cost for method B in Rs
q = (Ta-Tb)/(Pb-Pa) # break even point
print "Quantity of production at break even point = %d pieces"%(q)
```

In [34]:

```
# machine A
ic1 = 50000 # initial cost
hoc1 = 10 # hourly operating charges
pp1= 5 # pieces produced per hour
i = 15 # interest rate
i = i/100
oh = 2000 # operating hours
fc1 = ic1*i # fixed cost
vc1 = oh*hoc1 # variable cost
tc1 = fc1+vc1 # total charges
ao1 = oh*pp1 # annual output
c1 = tc1/ao1 # cost per unit
# machine B
ic2 = 80000 # initial cost
hoc2 = 8 # hourly operating charges
pp2= 8 # pieces produced per hour
fc2 = ic2*i # fixed cost
vc2 = oh*hoc2 # variable cost
tc2 = fc2+vc2 # total charges
ao2 = oh*pp2 # annual output
c2 = tc2/ao2 # cost per unit
print "(i) Cost per unit for machine A = Rs %0.2f\n Cost per unit machine B = Rs %0.2f"%(c1,c2)
print "machine B will be preferred"
# machine A
ao3 = 4000 # annual output
oc3 = ao3*hoc1/pp1 # operating charges
tc3 = oc3+fc1 # total annual charge
c3 = tc3/ao3 # cost/piece
# machine B
ao4 = 4000 # annual output
oc4 = ao4*hoc2/pp2 # operating charges
tc4 = oc4+fc2 # total annual charge
c4 = tc4/ao4# cost/piece
print "(ii) Cost per unit for machine A = Rs %0.2f\n Cost per unit machine B = Rs %0.2f"%(c3,c4)
print "machine A will be preferred"
A = hoc1/pp1 # operating cost per piece on machine A
B = hoc2/pp2 # operating cost per piece on machine B
Q = fc2 - fc1 # annual production
print "(iii) Annual production to make cost per piece equal for two machines = %d pieces"%(Q )
```

In [35]:

```
As = 80000 # annual sales in Rs
vc = 64000 # variable expenses in Rs
c = 16000 # contribution in Rs
fc = 24000 # fixed expenses in Rs
l = 8000 # losses in Rs
p = 9000 # profit in Rs
s1 = fc + vc # sales at B.E.P in Rs
s2 = (fc + vc + p)/0.945 # sales at net income of Rs9000 and corporate tax rate being 5.5%
q = 10000 # quantity of units
sp = (fc+vc)/q # selling price per unit in Rs
print " Sales at break even point = %d units"%(s1 )
print " Sales at net income of Rs9000 and corporate tax rate being 5.5 = Rs %0.2f\n Sales per unit if B.E.P brought down to 10000 units = Rs %0.2f per unit" %(s2 , sp)
```

In [36]:

```
fc = 55000 # fixed cost in Rs
vc = 45 # variable cost per piece in Rs
sp = 100 # selling price per piece in Rs
p = (vc/sp)*100 # percentage of variable cost to
pm = 100 - p # profit margin
bep = ((55000/55)*100)/100 # Break even point
print "Break even point = %d pieces"%(bep)
```

In [37]:

```
from math import sqrt
f1 = 335 # fixed cost in Rs for capstan lathe
k = 0.25 # stock carrying factor in paise per piece
k = k/100
N1 = sqrt(f1/k) # pieces for capstan lathe
a1 = 4.16 # variable cost per piece for capstan lathe
tc1 = a1+f1/N1+k*N1 # total cost for capstan lathe
f2 = 2120 # fixed cost in Rs for turret lathe
N2 = sqrt(f2/k) # pieces for turret lathe
a2 = 2.863 # variable cost per piece for turret lathe
tc2 = a2+f2/N2+k*N2 # total cost for turret lathe
print " Total cost per piece for capstan lathe = Rs %0.2f\n Total cost per piece for turret lathe = Rs %0.2f"%(tc1 , tc2)
# Answers vary due to round off error
```

In [38]:

```
from sympy import symbols, diff, solve
R=500 # cost of ordering in Rs per order
A=12000 #annual consumption units
C=3.00 # unit cost of item
K=1.5 # unit storage cost
I1=0.2 # interest rate
N = symbols('N')
G =C*A+I1*C*N/2+K*N/2+A*R/N # total cost per year
expr=G.diff(N)
N=solve(expr, N)[1]
O = A/N # number of orders
N1 = 2400 # units
tc = C*A + I1*C*N1/2 + K*N1/2 + A*R/N1 # total cost in Rs
I2 = (2*R*A)/(C*N1**2)
print " Economic order quantity = %d or %d units\n Totl cost = Rs %d per year\n I = %0.4f"%(N,N1,tc,I2)
print " It is clear that inventory cost will get increased very greatly"
```

In [39]:

```
from math import sqrt
A = 40000 # number of units per year
I = 25 # carrying cost in percent
I = I/100
C1 = 8 # cost for 0 < N < 1000 per unit in Rs
C2 = 7.5 # cost for 1000 < N < 10000 per unit in Rs
C3 = 7.25 # cost for N >= 10000 per unit in Rs
R = 250 # ordering cost per order in Rs
N = 10000 # units
N1 = sqrt(2*R*A/(I*C3)) # optimal quantity for lowest curve
G1= C3*A+(A*R)/N+I*C3*N/2 # total cost in Rs
N2 = sqrt(2*R*A/(I*C2)) # optimal quantity for higher curve
G2= C2*A+(A*R)/N2+I*C2*N2/2 # total cost in Rs
N3 = sqrt(2*R*A/(I*C1)) # optimal quantity for highest curve
G3 = C1*A+(A*R)+1 # total cost in Rs
print " Total cost for lowest cost curve = Rs %0.2f\n Total cost for next higher curve = Rs %0.2f\n Total cost for highest curve = Rs %0.2f "%(G1,G2,G3)
print " Comparing all total cost lowest is Rs 300,062.50 for an order quantity of 10,000."
print " N = 10,000 and No. of orders = 4"
```

In [40]:

```
from math import ceil
from sympy import symbols, diff, solve
c = 50000 # components
R=500 # cost of ordering in Rs per order
A=12000 #annual consumption units
C=3.00 # unit cost of item
K=1.50 # unit storage cost
I=0.2 # interest rate
N = symbols('N')
G=0.02*N+1500000/N
y=G.diff(N)
N=solve(y, N)[1]
l = c/N # number of lots
l = ceil(l)
ls = c/l # lot size
print "The lot size = %d components"%ls
```