In [3]:

```
##calculate the The ultimate strength and the yield strength
## initialization of variables
import math
## part (a)
a=700. ## M Pa from figure 1.8
b=100. ## M Pafrom figure 1.8
m=1/6. ## from figure 1.8
Y=450. ## M Pa from figure 1.9
##calculations
sigma_u=a+m*b
## results
print('\n part (a) \n')
print"%s %.2f %s"%(' The ultimate strength is sigma = ',sigma_u,' M Pa')
print"%s %.2f %s"%('\n and the yield strength is Y = ',Y,'M Pa')
## part (b)
c1=62. ## from figure 1.8
d1=0.025 ## from figure 1.8
c2=27. ## from figure 1.10a
d2=0.04 ## from figure 1.10a
## calculations
U_f1=c1*b*d1*10**6
U_f2=c2*b*d2*10**6
## results
print('\n part (b)')
print"%s %.2e %s"%('\n The modulus of toughness for alloy steel is Uf = ',U_f1,' N/m^2')
print"%s %.2e %s"%('\n and structural steel is Uf = ',U_f2,' N/m^2')
```

In [15]:

```
##calculate the permanet strain
## initialization of variables
import math
sigma=500. ## Stress M Pa
eps=0.0073 ## Strain
sigma_A=343. ## M Pa from figure 1.9
eps_A=0.00172 ## from figure 1.9
## part (a)
E=sigma_A/eps_A
## part (B)
eps_e=sigma/E
eps_p=eps-eps_e
## results
print(' part (a) \n')
print"%s %.2f %s"%(' The modulus of elasticity of the rod is E = ',E/1000,' G Pa')
print('\n part (b)')
print"%s %.4f %s"%('\n the permanent strain is = ',eps_p,'')
print"%s %.4f %s"%('\n and the strain recovered is =',eps_e,'')
```

In [14]:

```
##calculate the diameter
## initialization of variables
import math
D=25. ## kN
L=60. ## kN
W=30. ##kN
Y=250. ## M Pa
safety=5./3. ## AISC, 1989
## calculations
Q=(D+L+W)*10**3. ## converted to N
A=safety*Q/Y
r=math.sqrt(A/math.pi)+0.5 ## additional 0.5 mm is for extra safety
d=1.8*r ## diameter
## results
print('Part (a) \n ')
print"%s %.2f %s %.2f %s "%('A rod of ',d,' mm'and ' in diameter, with a cross sectional area of ',math.pi*(d**2./4.),' mm^2, is adequate')
## The diameter is correct as given in the textbook. Area doesn't match due to rounding off error and partly because it's a design problem.
```