example 4.1 page number 102¶

In :
from  math import cos,sin,pi

#variable declaration

L1=600.0      #length of wire AB,mm
L2=200.0      #length of wire BC,mm
L3=300.0      #length of wire CD,mm
theta=45*pi/180
#The wire is divided into three segments AB, BC and CD. Taking A as origin the coordinates of the centroids of AB, BC and CD are (X1,Y1),(X2,Y2),(X3,Y3)

X1=300.0
X2=600.0
X3=600.0-150*cos(theta)
Y1=0
Y2=100
Y3=200+150*sin(theta)
L=L1+L2+L3     #Total length,mm

xc=(L1*X1+L2*X2+L3*X3)/L

print "xc=",round(xc,2),"mm"

yc=(L1*Y1+L2*Y2+L3*Y3)/L

print "yc=",round(yc,2),"mm"
xc= 407.44 mm
yc= 101.65 mm

example 4.2 page number 103¶

In :
from math import  cos,sin,pi

#The composite figure is divided into three simple figures and taking A as origin coordinates of their centroids

#variable declaration

L1=400.0        #length of wire AB,mm
L2=150.0*pi     #length of wire BC,mm
L3=250.0        #length of wire CD,mm
theta=30*pi/180

#The wire is divided into three segments AB, BC and CD. Taking A as origin the coordinates of the centroids of AB, BC and CD are (X1,Y1),(X2,Y2),(X3,Y3)
X1=200.0
X2=475.0
X3=400+300.0+250*cos(theta)/2

Y1=0
Y2=2*150/pi
Y3=125*sin(theta)
L=L1+L2+L3     #Total length,mm

xc=(L1*X1+L2*X2+L3*X3)/L

print "xc=",round(xc,2),"mm"

yc=(L1*Y1+L2*Y2+L3*Y3)/L

print "yc=",round(yc,2),"mm"
xc= 451.2 mm
yc= 54.07 mm

example 4.3 page number 105¶

In :
from  math import cos,sin,pi
# The length and the centroid of portions AB, BC and CD
# portion AB is in x-z plane, BC in y-z plane and CD in x-y plane. AB and BC are semi circular in shape

#variable declaration

L1=100.0*pi        #length of wire AB,mm
L2=140.0*pi        #length of wire BC,mm
L3=300.0           #length of wire CD,mm
theta=45*pi/180

#The wire is divided into three segments AB, BC and CD. Taking A as origin the coordinates of the centroids of AB, BC and CD are (X1,Y1),(X2,Y2),(X3,Y3)
X1=100.0
X2=0
X3=300*sin(theta)

Y1=0
Y2=140
Y3=280+300*cos(theta)
Z1=2*100/pi
Z2=2*140/pi
Z3=0

L=L1+L2+L3     #Total length,mm

xc=(L1*X1+L2*X2+L3*X3)/L

print "xc=",round(xc,2),"mm"

yc=(L1*Y1+L2*Y2+L3*Y3)/L

print "yc=",round(yc,2),"mm"

zc=(L1*Z1+L2*Z2+L3*Z3)/L

print "zc=",round(zc,2),"mm"
xc= 90.19 mm
yc= 198.5 mm
zc= 56.17 mm

example 4.4 page number 111¶

In :
#variable declaration

A1=100.0*20.0        #Area of 1 ,mm^2
A2=20.0*100.0        #Area of 2,mm^2

X1=0
X2=0

Y1=10
Y2=70

A=A1+A2

xc=(A1*X1+A2*X2)/A

print "xc=",round(xc,2)

yc=(A1*Y1+A2*Y2)/A

print "yc=",round(yc,2),"mm"
print "Hence, centroid of T-section is on the symmetric axis at a distance 40 mm from the top"
xc= 0.0
yc= 40.0 mm
Hence, centroid of T-section is on the symmetric axis at a distance 40 mm from the top

example 4.5 page number 111¶

In :
#variable declaration

A1=150.0*12.0         #Area of 1 ,mm^2
A2=(200.0-12.0)*12.0        #Area of 2,mm^2

X1=75
X2=6

Y1=6
Y2=12+(200-12)/2

A=A1+A2

xc=(A1*X1+A2*X2)/A

print "xc=",round(xc,2)

yc=(A1*Y1+A2*Y2)/A

print "yc=",round(yc,2),"mm"

print "Thus, the centroid is at x = 36.62 mm and y = 61.62 mm "
xc= 36.62
yc= 61.62 mm
Thus, the centroid is at x = 36.62 mm and y = 61.62 mm

example 4.6 page number 112¶

In :
#variable declaration

A1=100.0*20              #Area of 1 ,mm^2
A2=100.0*20.0            #Area of 2,mm^2
A3=150.0*30.0            #Area of 3,mm^2

#Selecting the coordinate system, due to symmetry centroid must lie on y axis,

X1=0
X2=0

Y1=30+100+20/2
Y2=30+100/2
Y3=30/2

A=A1+A2+A3

yc=(A1*Y1+A2*Y2+A3*Y3)/A

print "yc=",round(yc,2),"mm"

print "Thus, the centroid is on the symmetric axis at a distance 59.71 mm from the bottom"
yc= 59.71 mm
Thus, the centroid is on the symmetric axis at a distance 59.71 mm from the bottom

example 4.7 page number 113¶

In :
# Note that it is convenient to take axis in such a way that the centroids of all simple figures are having positive coordinates. If coordinate of any simple figure comes out to be negative, one should be careful in assigning the sign of moment of area

#variable declaration

A1=2.0*6.0*1.0/2.0              #Area of 1,m^2
A2=2.0*7.5                      #Area of 2,m^2
A3=3.0*5.0*1.0/2                #Area of 3,m^2
A4=1.0*4.0                      #Area of 4,m^2

#The composite figure can be conveniently divided into two triangles and two rectangle

X1=2.0*2.0/3.0
X2=2.0+1.0
X3=2.0+2.0+(1.0*3.0/3.0)
X4=4.0+4.0/2.0

Y1=6.0/3.0
Y2=7.5/2.0
Y3=1.0+5.0/3.0
Y4=1/2.0

A=A1+A2+A3+A4

xc=(A1*X1+A2*X2+A3*X3+A4*X4)/A

print "xc=",round(xc,3),"m"

yc=(A1*Y1+A2*Y2+A3*Y3+A4*Y4)/A

print "yc=",round(yc,3),"m"
xc= 3.523 m
yc= 2.777 m

example 4.8 page number 114¶

In :
# The composite section is divided into three simple figures, a triangle, a rectangle and a semicircle

from math import pi
#variable declaration

A1=1.0*3.0*4.0/2.0                  #Area of 1,m^2
A2=6.0*4.0                          #Area of 2,m^2
A3=1.0*pi*pow(2,2)/2                #Area of 3,m^2

#The coordinates of centroids of these three simple figures are:

X1=6.0+3.0/3.0
X2=3.0
X3=-(4*2)/(3.0*pi)

Y1=4.0/3.0
Y2=2.0
Y3=2.0

A=A1+A2+A3

xc=(A1*X1+A2*X2+A3*X3)/A

print "xc=",round(xc,4),"m"

yc=(A1*Y1+A2*Y2+A3*Y3)/A

print "yc=",round(yc,3),"m"
xc= 2.995 m
yc= 1.89 m

example 4.9 page number 115¶

In :
#The composite area is equal to a rectangle of size 160 × 280 mm plus a triangle of size 280 mm base width and 40 mm height and minus areas of six holes. In this case also the can be used for locating centroid by treating area of holes as negative. The area of simple figures and their centroids are

from math import pi

#variable declaration

Ar=160.0*280.0                  #Area of rectangle,mm^2
At=280.0*40.0/2.0                          #Area of triangle,mm^2
d=21.5                              #diameter of hole,mm
Ah=-pi*pow(d,2)/4                   #Area of hole,mm^2

A=Ar+At+Ah*6

Xr=140.0
Xt=560/3.0
Xh1=70.0
Xh2=140.0
Xh3=210.0
Xh4=70.0
Xh5=140.0
Xh6=210.0

Yr=80.0
Yt=160.0+40.0/3.0
Yh1=50.0
Yh2=50.0
Yh3=50.0
Yh4=120.0
Yh5=130.0
Yh6=140.0

xc=(Ar*Xr+At*Xt+Ah*(Xh1+Xh2+Xh3+Xh4+Xh5+Xh6))/A

print "xc=",round(xc,2),"m"

yc=(Ar*Yr+At*Yt+Ah*(Yh1+Yh2+Yh3+Yh4+Yh5+Yh6))/A

print "yc=",round(yc,2),"m"
xc= 145.42 m
yc= 90.39 m

example 4.10 page number 116¶

In :
# If xc and yc are the coordinates of the centre of the circle, centroid also must have the coordinates xc and yc as per the condition laid down in the problem. The shaded area may be considered as a rectangle of size 200 mm × 150 mm minus a triangle of sides 100 mm × 75 mm and a circle of diameter 100 mm.

from math import pi
#variable declaration

Ap=200.0*150.0                              #Area of plate,mm^2
At=100.0*75.0/2.0                           #Area of triangle,mm^2
Ah=pi*pow(100,2)/4.0                        #Area of hole ,mm^2

A=Ap-At-Ah

X1=100.0
X2=200.0-100.0/3.0
#X3=Xc

Y1=75.0
Y2=150.0-25.0
#Y3=Yc

A=Ap-At-Ah

xc=(Ap*X1-At*X2)/(Ah+A)

print "xc=",round(xc,2),"mm"

yc=(Ap*Y1-At*Y2)/(Ah+A)

print "yc=",round(yc,2),"mm"
xc= 90.48 mm
yc= 67.86 mm

example 4.11 page number 118¶

In :
from math import pi

#variable declaration
X=40.0
A1=14.0*12.0*pow(X,2)                           #Area of rectangle,mm^2
A2=6.0*4.0*pow(X,2)/2.0                         #Area of triangle,mm^2
A3=-4*4*pow(X,2)                                #Area of removed subtracted,mm^2
A4=-pi*pow(4*X,2)/2.0                           #Area of semicircle to be subtracted,mm^2
A5=-pi*pow(4*X,2)/4.0                           #Area of quarter of circle to be subtracted,mm^2

X1=7.0*X
X2=14*X+2*X
X3=2*X
X4=6.0*X
X5=14.0*X-(16*X/(3*pi))

Y1=6.0*X
Y2=4.0*X/3.0
Y3=8.0*X+2.0*X
Y4=(16.0*X)/(3*pi)
Y5=12*X-4*(4*X/(3*pi))

A=A1+A2+A3+A4+A5

xc=(A1*X1+A2*X2+A3*X3+A4*X4+A5*X5)/A

print "xc=",round(xc,2),"m"

yc=(A1*Y1+A2*Y2+A3*Y3+A4*Y4+A5*Y5)/A

print "yc=",round(yc,2),"m"
xc= 326.4 m
yc= 219.12 m

example 4.12 page number 130¶

In :
#The given composite section can be divided into two rectangles

from math import pi,sqrt
#variable declaration

A1=150.0*10.0                         #Area of 1,mm^2
A2=140.0*10.0                         #Area of 2,mm^2
A=A1+A2                               #Total area,mm^2
#Due to symmetry, centroid lies on the symmetric axis y-y. The distance of the centroid from the top most fibre is given by:

Y1=5.0
Y2=10.0+70.0

yc=(A1*Y1+A2*Y2)/A

#Referring to the centroidal axis x-x and y-y, the centroid of A1 is g1 (0.0, yc-5) and that of A2 is g2 (0.0, 80-yc)

#Moment of inertia of the section about x-x axis Ixx = moment of inertia of A1 about x-x axis + moment of inertia of A2 about x-x axis.

Ixx=(150*pow(10,3)/12)+(A1*pow((yc-5),2))+(10*pow(140,3)/12)+(A2*pow((80-yc),2))

print "Ixx=",round(Ixx,1),"mm^4"

Iyy=(10*pow(150,3)/12)+(140*pow(10,3)/12)

print "Iyy=",round(Iyy,1),"mm^4"

#Hence, the moment of inertia of the section about an axis passing through the centroid and parallel to the top most fibre is Ixxmm^4 and moment of inertia of the section about the axis of symmetry is Iyy mm^4.
#The radius of gyration is given by

kxx=sqrt(Ixx/A)
print"kxx=",round(kxx,2),"mm"

kyy=sqrt(Iyy/A)
print"kyy=",round(kyy,2),"mm"
Ixx= 6372441.9 mm^4
Iyy= 2824166.0 mm^4
kxx= 46.88 mm
kyy= 31.21 mm

example 4.13 page number 131¶

In :
#The given composite section can be divided into two rectangles

#variable declaration

A1=125.0*10.0                         #Area of 1,mm^2
A2=75.0*10.0                         #Area of 2,mm^2
A=A1+A2                               #Total area,mm^2

#First, the centroid of the given section is to be located. Two reference axis (1)–(1) and (2)–(2)

#The distance of centroid from the axis (1)–(1)

X1=5.0
X2=10.0+75.0/2

xc=(A1*X1+A2*X2)/A

#Similarly, the distance of the centroid from the axis (2)–(2)

Y1=125.0/2
Y2=5.0

yc=(A1*Y1+A2*Y2)/A

#With respect to the centroidal axis x-x and y-y, the centroid of A1 is g1 (xc-5, (85/2)-xc) and that of A2 is g2 ((135/2)-yc, yc-5).
Ixx=(10*pow(125,3)/12)+(A1*pow(21.56,2))+(75.0*pow(10.0,3.0)/12)+(A2*pow((39.94),2))

print "Ixx=",round(Ixx,1),"mm^4"

Iyy=(125*pow(10,3)/12)+(A1*pow(15.94,2))+(10*pow(75,3)/12)+(A2*pow(26.56,2))

print "Iyy=",round(Iyy,1),"mm^4"

#Izz=Polar moment of inertia

Izz=Ixx+Iyy

print "Izz=",round(Izz,1),"mm^4"
Ixx= 3411298.7 mm^4
Iyy= 1208657.7 mm^4
Izz= 4619956.4 mm^4

eample 4.14 page number 132¶

In :
#The given composite section can be divided into two rectangles

#variable declaration

A1=200.0*9.0                               #Area of 1,mm^2
A2=(250.0-9*2)*6.7                         #Area of 2,mm^2
A3=200.0*9.0                               #Area of 3,mm^2
A=A1+A2+A3                                 #Total area,mm^2

#The section is symmetrical about both x-x and y-y axis.
X1=0
X2=0
X3=0

xc=(A1*X1+A2*X2+A3*X3)/A

Y1=245.5
Y2=125.0
Y3=4.5

yc=(A1*Y1+A2*Y2+A3*Y3)/A

#Therefore, its centroid will coincide with the centroid of rectangle A2. With respect to the centroidal axis x-x and y-y, the centroid of rectangle A1 is g1 (0.0, 120.5), that of A2 is g2 (0.0, 0.0) and that of A3 is g3 (0.0, 120.5).

Ixx=(200.0*pow(9,3)/12)+(A1*pow(yc-4.5,2))+(6.7*pow(232,3.0)/12)+0+(200*pow(9,3)/12)+(A3*pow((yc-4.5),2))

print "Ixx=",round(Ixx,1),"mm^4"

Iyy=(9*pow(200,3)/12)+(232*pow(6.7,3)/12)+(9*pow(200,3)/12)

print "Iyy=",round(Iyy,1),"mm^4"

#Izz=Polar moment of inertia

Izz=Ixx+Iyy

#misprint in book

print "Izz=",round(Izz,1),"mm^4"
Ixx= 59269202.1 mm^4
Iyy= 12005814.8 mm^4
Izz= 71275016.9 mm^4

example4.15 page number 133¶

In :
from math import sqrt

#variable declaration

A1=100.0*13.5                               #Area of 1,mm^2
A2=(400.0-27.0)*8.1                         #Area of 2,mm^2
A3=100.0*13.5                               #Area of 3,mm^2

A=A1+A2+A3                                 #Total area,mm^2

#The given section is symmetric about horizontal axis passing through the centroid g2 of the rectangle A2.

X1=50.0
X2=8.1/2.0
X3=50.0

xc=(A1*X1+A2*X2+A3*X3)/A

Y1=386.5+13.5/2.0
Y2=200.0
Y3=13.5/2

yc=(A1*Y1+A2*Y2+A3*Y3)/A

#With reference to the centroidal axis x-x and y-y

Ixx=(100.0*pow(13.5,3)/12.0)+(A1*pow((200-(13.5/2)),2))+(8.1*pow(373,3.0)/12.0)+0+(100*pow(13.5,3)/12.0)+(A3*pow((200-(13.5/2)),2))
print "Ixx=",round(Ixx,1),"mm^4"

Iyy=(13.5*pow(100.0,3)/12.0)+(A1*pow((50-xc),2))+(373.0*pow(8.1,3.0)/12.0)+A2*pow(21.68,2)+(13.5*pow(100,3)/12.0)+(A3*pow((50-xc),2))

print "Iyy=",round(Iyy,1),"mm^4"
Ixx= 135903229.0 mm^4
Iyy= 5276363.1 mm^4

example 4.16 page number 134¶

In :
# The section is divided into three rectangles A1, A2 and A3

from math import sqrt,pi

#variable declaration

A1=80.0*12.0                                 #Area of 1,mm^2
A2=(150.0-22.0)*12.0                         #Area of 2,mm^2
A3=120.0*10.0                                #Area of 3,mm^2

A=A1+A2+A3                                   #Total area,mm^2

#Due to symmetry, centroid lies on axis y-y. The bottom fibre (1)–(1) is chosen as reference axis to locate the centroid

Y1=150-6
Y2=(128/2) +10
Y3=5

yc=(A1*X1+A2*X2+A3*X3)/A

X1=60.0
X2=60.0
X3=60.0

xc=(A1*Y1+A2*Y2+A3*Y3)/A

#With reference to the centroidal axis x-x and y-y, the centroid of the rectangles A1 is g1 (0.0, 150-6-yc), that of A2 is g2 (0.0, 75-yc) and that of A3 is g3  (0.0, yc-5 ).

Iyy=(12*(pow(80,3))/12)+(128*(pow(12,3))/12)+(10*(pow(120,3))/12)

Ixx=(80.0*pow(12.0,3)/12.0)+(A1*pow((150-6-yc),2))+(12*pow(128,3.0)/12.0)+(A2*pow((75-yc),2))+(120*pow(10,3)/12.0)+(A3*pow((150-10-6-yc),2))

PolarmomentofInertia=Ixx+Iyy

print "Polar moment of Inertia=",round(PolarmomentofInertia),"mm^4"

kxx=sqrt(Ixx/A)
print "kxx=",round(kxx,2),"mm"

kyy=sqrt(Iyy/A)
print "kyy=",round(kyy,2),"mm"
Polar moment of Inertia= 32109472.0 mm^4
kxx= 90.3 mm
kyy= 23.09 mm

example4.17 page number 135¶

In :
from math import sqrt

#The given composite section may be divided into simple rectangles and triangle

#variable declaration

A1=100.0*30.0                               #Area of 1,mm^2
A2=100.0*25.0                               #Area of 2,mm^2
A3=200.0*20.0                               #Area of 3,mm^2
A4=87.5*20.0/2.0                            #Area of 4,mm^2
A5=87.5*20.0/2.0                            #Area of 5,mm^2

A=A1+A2+A3+A4+A5                            #Total area,mm^2

#Due to symmetry, centroid lies on the axis y-y. A reference axis (1)–(1) is choosen as shown in the figure. The distance of the centroidal axis from (1)–(1)

X1=100.0
X2=100.0
X3=100.0
X4=2.0*87.5/3.0
X5=200-X4
xc=(A1*X1+A2*X2+A3*X3+A4*X4+A5*X5)/A

Y1=135.0
Y2=70.0
Y3=10.0
Y4=(20.0/3.0)+20.0
Y5=Y4

yc=(A1*Y1+A2*Y2+A3*Y3+A4*Y4+A5*Y5)/A

#With reference to the centroidal axis x-x and y-y, the centroid of the rectangle A1 is g1 (0.0,135.0-yc), that of A2 is g2(0.0,70.00-yc), that of A3 is g3 (0.0, yc-10.0), the centroid of triangle A4 is g4 (41.66,yc-20.0-(20.0/3.0) ) and that of A5 is g5 (41.66,yc-20.0-(20.0/3.0)).

Ixx=(100.0*pow(30,3)/12.0)+(A1*pow((135.0-yc),2))+(25.0*pow(100,3.0)/12.0)+(A2*pow((70.0-yc),2))+(200*pow(20,3)/12.0)+(A3*pow((yc-10.0),2))+((87.5*pow(20,3)/36.0)+(A4*pow((yc-20.0-(20.0/3.0)),2)))*2

print "Ixx=",round(Ixx,1),"mm^4"

Iyy=(30.0*pow(100,3)/12.0)+(100.0*pow(25,3.0)/12.0)+(20*pow(200,3)/12.0)+((20.0*pow(87.5,3)/36.0)+(A4*pow((41.66),2)))*2

print "Iyy=",round(Iyy,1),"mm^4"
Ixx= 31543827.2 mm^4
Iyy= 19745121.6 mm^4

example4.18 page number137¶

In :
#In this problem, it is required to find out the moment of inertia of the section about an axis AB. So there is no need to find out the position of the centroid.
#The given section is split up into simple rectangles
#Moment of inertia about AB = Sum of moments of inertia of the rectangle about AB

#variable declaration

A1=400*20.0
A2=100*10
A3=10*380.0
A4=100*10.0

IAB=(400.0*pow(20,3)/12)+(A1*pow(10,2))+((100*pow(10,3)/12)+(A2*pow(25,2)))*2+((10*pow(380,3)/12)+(A3*pow(220,2)))*2+((100*pow(10,3)/12)+(A4*pow(415,2)))*2

print "IAB=",round(IAB),"mm^4"
IAB= 806093331.0 mm^4

example4.19 page number 137¶

In :
# The built-up section is divided into six simple rectangles

#variable declaration

A1=250.0*10.0                               #Area of 1,mm^2
A2=40.0*10.0                                #Area of 2,mm^2

A=A1*2+A2*4                                 #Total area,mm^2

Y1=5.0
Y2=30.0
Y3=15.0
Y4=255.0
Y5=135.0

yc=(A1*Y1+2*A2*Y2+A2*Y3+A2*Y4+A1*Y5)/A

#Now, Moment of inertia about the centroidalaxis=Sum of the moment of inertia of the individual rectangles

Ixx=(250.0*pow(10,3)/12.0)+(A1*pow((yc-5),2))+((10.0*pow(40,3.0)/12.0)+(A2*pow((yc-30.0),2)))*2+(40*pow(10,3)/12.0)+(A2*pow((yc-15.0),2))+(10.0*pow(250.0,3.0)/12.0)+(A1*pow((yc-135.0),2))+(40.0*pow(10.0,3)/12)+(A2*pow((yc-255),2))

print "Ixx=",round(Ixx,1),"mm^4"
Ixx= 50399393.9 mm^4

example4.20 page number 138¶

In :
#Each angle is divided into two rectangles

#variable declaration

A1=600.0*15.0                               #Area of 1,mm^2
A2=140.0*10.0                                #Area of 2,mm^2
A3=150.0*10.0
A4=400.0*20.0
A=A1+A2*2+A3*2+A4                                 #Total area,mm^2

#The distance of the centroidal axis from the bottom fibres of section

Y1=320.0
Y2=100.0
Y3=25.0
Y4=10.0

yc=(A1*Y1+2*A2*Y2+A3*Y3*2+A4*Y4)/A
print yc
#Now, Moment of inertia about the centroidalaxis=Sum of the moment of inertia of the individual rectangles

Ixx=(15.0*pow(600,3)/12.0)+(A1*pow((yc-320),2))+((10.0*pow(140,3.0)/12.0)+(A2*pow((yc-100.0),2)))*2+((150*pow(10,3)/12.0)+(A3*pow((yc-15.0),2)))*2+(400.0*pow(20.0,3.0)/12.0)+(A4*pow((yc-10.0),2))

print "Ixx=",round(Ixx,1),"mm^4"
145.394736842
Ixx= 752680131.6 mm^4

example4.21 page number 139¶

In :
from math import asin,sin,cos,pi

#The rectangle is divided into four triangles
#The lines AE and FC are parallel to x-axis

#variable declaration

theta=asin(4.0/5.0)

AB=100.0
BK=AB*sin((90*pi/180)-theta)
ND=BK
FD=60.0/sin(theta)
AF=150.0-FD
FL=ME=75.0*sin(theta)
AE=AB/cos((90*pi/180)-theta)
FC=AE
A=125.0*60.0/2.0

#Moment of inertia of the section about axis x-x=Sum of the momentsof inertia of individual triangular areasabout axis

Ixx=(125*pow(60,3)/36)+(A*pow((ND*4.0/3.0),2))+(125*pow(60,3)/36)+(A*pow((ND*2.0/3.0),2))+(125*pow(60,3)/36)+(A*pow((ND*1.0/3.0),2))+(125*pow(60,3)/36)+(A*pow((ND*1.0/3.0),2))

print "Ixx=",round(Ixx),"mm^4"
Ixx= 36000000.0 mm^4

example 4.22, page number 140¶

In :
from math import pi

#The section is divided into a triangle PQR, a semicircle PSQ having base on axis AB and a circle having its centre on axis AB

#variable declaration
#Now,Moment of inertia of the section about axis AB
IAB=(80*pow(80,3)/12)+(pi*pow(80,4)/128)-(pi*pow(40,4)/64)

print "IAB=",round(IAB),"mm^4"
IAB= 4292979.0 mm^4

example4.23 page number141¶

In :
from math import pi

#The section is divided into three simple figures viz., a triangle ABC, a rectangle ACDE and a semicircle.

#variable declaration

A1=80.0*20.0/2         #Area of triangle ABC
A3=40.0*80.0           #Area of rectangle ACDE
A4=pi*pow(r,2)/2       #Area of semicircle
At1=30.0*20.0/2.0
At2=50.0*20.0/2.0
A=A1+A3-A4             #Total area

X1=2.0*30.0/3.0
X2=50.0*30.0/3.0
X3=40.0
X4=40.0

xc=(At1*X1+At2*X2+A3*X3-A4*X4)/A
#mistake in book

Y1=(20.0/3.0)+40.0
Y3=20.0
Y4=(4.0*20.0)/(3.0*pi)

yc=(A1*Y1+A3*Y3-A4*Y4)/A
print xc,yc
#
#Moment of inertia of the section about axis x-x=Sum of the momentsof inertia of individual triangular areasabout axis

Ixx=(80.0*pow(20.0,3)/36) +A1*pow((60.0-(2*20.0/3.0)-yc),2)+(80*pow(40,3)/12)+(A3*pow((yc-20.0),2))-((0.0068598*pow(20,4))+(A4*pow((yc-Y4),2)))

print"Ixx=",round(Ixx),"mm^4"

Iyy=(20.0*pow(30.0,3)/36) +At1*pow((xc-(2*30.0/3.0)),2)+(20*pow(50,3)/36)+(At2*pow((xc-(30.0+(50/3))),2))+((40*pow(80,3)/12)+(A3*pow((xc-40),2)))-((pi*pow(40,4))/(2*64))-(A4*pow((40-xc),2))

print"Iyy=",round(Iyy),"mm^4"
106.435694487 28.4724404943
Ixx= 686943.0 mm^4
Iyy= 17146488.0 mm^4

example 4.27 page number 150¶

In :
#A concrete block of size 0.60 m × 0.75 m × 0.5 m is cast with a hole of diameter 0.2 m and depth 0.3 m
#The hole is completely filled with steel balls weighing 2500 N. Locate the centre of gravity of the body.

from math import pi

#variable declaration

W=25000.0                    # weight of concrete=25000, N/m^3
W1=0.6*0.75*0.5*W           #Weight of solid concrete block
W2=pi*pow(0.2,2)*0.3*W/4  #Weight of concrete (W2) removed for making hole:
W3=2500

#Taking origin as shown in the figure, the centre of gravity of solid block is (0.375, 0.3, 0.25) and that of hollow portion is (0.5, 0.4, 0.15)

X1=0.375
X2=0.5
X3=0.5

Y1=0.3
Y2=0.4
Y3=0.4

Z1=0.25
Z2=0.15
Z3=0.15

Wt=W3+W1-W2
print W,W1,W2,Wt
xc=(W1*X1-W2*X2+W3*X3)/Wt

yc=(W1*Y1-W2*Y2+W3*Y3)/Wt

zc=(W1*Z1-W2*Z2+W3*Z3)/Wt

print"xc=",round(xc,3),"m"
print"yc=",round(yc,3),"m"
print"zc=",round(zc,3),"m"
25000.0 5625.0 235.619449019 7889.38055098
xc= 0.411 m
yc= 0.329 m
zc= 0.221 m