In [2]:

```
# -*- coding: utf8 -*-
from __future__ import division
#Example: 2.1
'''What is the weight of a 1 kg mass at an altitude where the local acceleration of gravity is
9.75 m/s2?'''
#Variable Declaration:
m = 1 #Mass in kg
g = 9.75 #Acc.due to gravity in m/s**2
#Calculation:
F = m*g #Weight of 1 kg mass in N
#Result
print "Weight of person is:",round(F,2),"N"
```

In [3]:

```
# -*- coding: utf8 -*-
from __future__ import division
#Example: 2.2
'''A1m3 container, shown in Fig. 2.9, is filled with 0.12 m3 of granite, 0.15 m3 of sand, and
0.2 m3 of liquid 25◦C water; the rest of the volume, 0.53 m3, is air with a density of 1.15
kg/m3. Find the overall (average) specific volume and density.'''
#Variable Declaration:
Vliq = 0.2 #volume of liquid in m**3
dliq = 997 #density of liquid in kg/m**3
Vstone = 0.12 #volume of stone in m**3
Vsand = 0.15 #volume of sand in m**3
Vair = 0.53 #voume of air in m**3
dstone = 2750 #density of stone in kg/m**3
dsand = 1500 #density of sand in kg/m**3
Vtot = 1 #total volume in m**3
dair = 1.1 #density of air in kg/m**3
#Calculation:
mliq = Vliq*dliq #mass of liquid in kg
mstone = Vstone*dstone #volume of stone in m**3
msand = Vsand*dsand #volume of sand in m**3
mair = Vair*dair #mass of air
mtot = mair+msand+mliq+mstone #total mass in kg
v = Vtot/mtot #specific volume in m**3/kg
d = 1/v #overall density in kg/m**3
#Results:
print "Average specific volume is: ",round(v ,6),"m**3/kg"
print "Overall density is:",round(d),"kg/m**3"
```

In [4]:

```
# -*- coding: utf8 -*-
from __future__ import division
#Example: 2.3
'''The hydraulic piston/cylinder system shown in Fig. 2.11 has a cylinder diameter of D =
0.1 m with a piston and rod mass of 25 kg. The rod has a diameter of 0.01 m with an
outside atmospheric pressure of 101 kPa. The inside hydraulic fluid pressure is 250 kPa.
How large a force can the rod push within the upward direction?'''
from math import pi
#Variable Declaration:
Dcyl = 0.1 #Cylinder diameter in m
Drod = 0.01 #Rod diameter in m
Pcyl = 250000 #Inside hydaulic pressure in Pa
Po = 101000 #Outside atmospheric pressure in kPa
g = 9.81 #Acc. due to gravity in m/s**2
mp = 25 #Mass of (rod+piston) in kg
#Calculation:
Acyl = pi*Dcyl**2/4 #Cross sectional area of cylinder in m**2
Arod = pi*Drod**2/4 #Cross sectional area of rod in m**2
F = Pcyl*Acyl-Po*(Acyl-Arod)-mp*g #Force that rod can push within the upward direction in N
#Result:
print "Force that rod can push within the upward direction is:",round(F,1),"N"
```

In [5]:

```
# -*- coding: utf8 -*-
from __future__ import division
#Example: 2.4
'''A mercury barometer located in a room at 25◦C has a height of 750 mm. What is the
atmospheric pressure in kPa?'''
#Variable Declaration:
dm = 13534 #Density of mercury in kg/m**3
H = 0.750 #Height difference between two columns in metres
g = 9.80665 #Acc. due to gravity in m/s**2
#Calculation:
Patm = dm*H*g/1000 #Atmospheric pressure in kPa
#Result:
print "Atmospheric pressure is:",round(Patm,2),"KPa"
```

In [6]:

```
# -*- coding: utf8 -*-
from __future__ import division
#Example: 2.5
'''A mercury (Hg) manometer is used to measure the pressure in a vessel as shown in
Fig. 2.13. The mercury has a density of 13 590 kg/m3, and the height difference between the
two columns is measured to be 24 cm.We want to determine the pressure inside the vessel.'''
#Variable Declaration:
dm = 13590 #Density of mercury in kg/m**3
H = 0.24 #Height difference between two columns in metres
g = 9.80665 #Acc. due to gravity in m/s**2
Patm = 13590*0.750*9.80665 #Atmospheric Pressure in Pa
#Calculation:
dP = dm*H*g #Pressure difference in Pa
Pvessel = dP+Patm #Absolute Pressure inside vessel in Pa
#Result:
print "Absolute pressure inside vessel is:",round(Pvessel/101325,2),"atm"
```

In [7]:

```
# -*- coding: utf8 -*-
from __future__ import division
#Example: 2.6
'''What is the pressure at the bottom of the 7.5-m-tall storage tank of fluid at 25◦C shown
in Fig. 2.15? Assume that the fluid is gasoline with atmospheric pressure 101 kPa on the
top surface. Repeat the question for the liquid refrigerant R-134a when the top surface
pressure is 1 MPa.'''
#Variable Declaration:
dg = 750 #Density of gaasoline in kg/m**3
dR = 1206 #Density of R-134a in kg/m**3
H = 7.5 #Height of storage tank in metres
g = 9.807 #Acc. due to gravity in m/s**2
Ptop1 = 101 #Atmospheric pressure in kPa
Ptop2 = 1000 #top surface pressure in kPa
#Calculation:
dP1 = dg*g*H/1000 #Pressure difference in kPa
P1 = dP1+Ptop1
dP2 = dR*g*H/1000#Pressure difference in kPa
P2 = dP2+Ptop2
#Result:
print "Pressure at the bottom of storage tank if liquid is Gasoline:",round(P1,1),"Kpa"
print "Pressure at the bottom of storage tank if liquid is R-134a:",round(P2),"Kpa"
```

In [8]:

```
# -*- coding: utf8 -*-
from __future__ import division
#Example: 2.7
'''A piston/cylinder with a cross-sectional area of 0.01 m2 is connected with a hydraulic
line to another piston/cylinder with a cross-sectional area of 0.05 m2. Assume that both
chambers and the line are filled with hydraulic fluid of density 900 kg/m3 and the larger
second piston/cylinder is 6mhigher up in elevation. The telescope armand the buckets have
hydraulic piston/cylinders moving them, as seen in Fig. 2.16.With an outside atmospheric
pressure of 100 kPa and a net force of 25 kN on the smallest piston, what is the balancing
force on the second larger piston?'''
#Variable Declaration:
Po = 100 #Outside atmospheric pressure in kPa
F1 = 25 #Net force on the smallest piston in kN
A1 = 0.01 #Cross sectional area of lower piston in m**2
d = 900 #Density of fluid in kg/m**3
g = 9.81 #Acc. due to gravity in m/s**2
H = 6 #Height of second piston in comparison to first one in m
A2 = 0.05 #Cross sectional area of higher piston in m**3
#Calculation:
P1 = Po+F1/A1 #Fluid pressure in kPa
P2 = P1-d*g*H/1000 #Pressure at higher elevation on piston 2 in kPa
F2 = (P2-Po)*A2 #Balancing force on second piston in kN
#Result:
print "Balancing force on second larger piston is:",round(F2,4),"N"
```