chapter3-Work energy and heat first law of thermodynamics

Example 3 - Pg 25

In [2]:
import math
##calculate the work interaction of spring
##initialisation of variables
m= 5 ##kg
g= 9.8 ##m/sec^2
k= 500 ##N/m
##CALCULATIONS
x= m*g/k
W= -m*g*x
##RESULTS
print'%s %.2f %s'% ('work interaction of spring = ',W,'J')
work interaction of spring =  -4.80 J

Example 4 pg 27

In [3]:
import math
##calculate the work done by the gas
##initialisation of variables
m= 500 ##kg
V= 50 ##L
P= 700 ##kPa
T= 25 ##C
P0= 100 ##kPa
g= 9.8 ##m/sec^2
A= 200 ##cm^2
V1= 100 ##L
##CALCULATIONS
pe= P0*math.pow(10,3)+(m*g/(A*(math.pow(10,-4))))
W= pe*(V1-V)*(math.pow(10,-6))
##RESULTS
print'%s %.2f %s'% ('work of the gas =',W,'kJ')
work of the gas = 17.25 kJ

Example 5 pg 32

In [4]:
import math
##calcualte the energy change in process 1,2,3 and work in third process
##initialisation of variables
W= 5 ##kJ
Q= 23 ##kJ
Q1= -50 ##kJ
W1= 0 ##kJ
##CALCULATIONS
E1= Q-W
E2= Q1-W1
E3= -(E1+E2)
W3= -E3
##RESULTS
print '%s %.f %s'%('energy change in process 1 =',E1,'kJ')
print'%s %.f %s'% ('energy change in process 2 = ',E2,'kJ')
print '%s %.f %s'%('energy change in process 3 = ',E3,'kJ')
print '%s %.f %s'%('Work in third process = ',W3,'kJ')
energy change in process 1 = 18 kJ
energy change in process 2 =  -50 kJ
energy change in process 3 =  32 kJ
Work in third process =  -32 kJ

Example 6 pg 34

In [5]:
import math
##calculat the car mileage of given variable
##initialisation of variables
V= 12 ##km/L
##CALCULATIONS
MPG= V*3.7854/1.609
##RESULTS
print'%s %.2f %s'%('car mileage =',MPG,'MPG')
car mileage = 28.23 MPG

Example 7 pg 35

In [6]:
import math
##find whether salesman is honest or not
##initialisation of variables
p= 800 ##atm
P= 10000 ##psi
x= 14.696 ##psi/atm
##CALCULATIONS
P1= p*x
##RESULTS
if (P1>P):
	print ("Salesman is honest")
Salesman is honest