In [1]:

```
import math #Example 12_1
#To find the work done by the gas
d1=800 #Units in meter**3
d2=500 #Units in meter**3
p1=5*10**5 #Units in Pa
w1=p1*(d1-d2)*10**-6 #Units in J
p2=2*10**5 #Units in Pa
d3=200*10**-6 #Units in meter**3
p3=3*10**5 #Units in Pa
w2=(p2*d3)+(0.5*p3*d3) #Units in J
print "The work done by the gas is=",round(-(w1+w2))," J"
```

In [2]:

```
import math #Example 12_2
#To estimate the Cv of nitric acid
r=8314 #Units in J/Kmol K
m=30 #Units in Kg/Kmol
Cv=2.5*(r/m) #Units in J/Kg K
print "The estimated Cv value of nitric acid is Cv=",round(Cv)," J/Kg K"
#in textbook the answer is printed wrong as Cv=690 J/Kg K correct answer is 692 J/Kg K
```

In [3]:

```
import math #Example 12_3
#To find the final temperature
t1=27 #units in Centigrade
t1=t1+273 #Units in K
gama=1.4 #Units in Constant
p1=1 #units in Pa
v1_v2=15 #Units of in ratio
logT2=math.log10(t1)-((gama-1)*(math.log10(p1)-math.log10(v1_v2)))
T2=10**logT2 #Uniys in K
print "The final temperature is T2=",round(T2)," K"
```

In [4]:

```
import math #Example 12_4
#To describe the Temperature changes of the gas
print "This type of process is termed as throttling process and described by the equation Delta U=- Delta W\n"
print "Where Delta W is the work done"
```

In [5]:

```
import math #Example 12_5
#To findout by how much the entropy of the system changes
m=20 #Units in gm
alpha=80 #Units in cal/gm
t=4.184 #Units in J/Cal
Q=m*alpha*t #Units in J
T=273 #Units in K
S=Q/T #Units in J/K
print "The entropy is Delta S=",round(S,1)," J/K"
```

In [6]:

```
import math #Example 12_6
#To findout how much electricity is needed
Tc=278 #Units in K
Th=293 #Units in K
COP=Tc/(Th-Tc) #Units in ratio
Qc=210000 #Units in J
W=Qc/COP #Units in J
print "The amount of Electricity is required is Delta W=",round(W)," J"
```