In [4]:

```
from math import pi
from math import log
from math import exp
#variable declaration
D_i=0.505;
L=2;
P_max=20000;
P_f=16000;
D_f=0.425;
#calculation
E_St= P_max*4/(pi*D_i**2);
T_fr_St= P_f*4/(pi*D_f**2);
e_f=log(D_i**2/D_f**2);
e=exp(e_f)-1;
#result
print('\nEngineering Stress at maximum load = %g psi\nTrue Fracture Stress = %g psi\nTrue Strain at fracture = %g\nEngineering strain at fracture = %g')%(E_St,T_fr_St,e_f,e);
```

In [2]:

```
from math import sqrt
#variable declaration
sigma00=500;
sigma_z=-50;
sigma_y=100;
sigma_x=200;
T_xy=30;
T_yz=0;
T_xz=0;
#calculation
sigma0=sqrt((sigma_x-sigma_y)**2+(sigma_y-sigma_z)**2+(sigma_z-sigma_x)**2+6*(T_xy**2+T_yz**2+T_xz**2))/sqrt(2);
s=sigma00/sigma0;
#result
print('\nSince the calculated value of sigma0 = %g MPa, which is less than the yield strength of the aluminium alloy\nThus safety factor is = %g')%(sigma0,s);
```

In [6]:

```
#variable declaration
sigma00=500;
sigma_z=-50;
sigma_y=100;
sigma_x=200;
T_xy=30;
T_yz=0;
T_xz=0;
#calculation
sigma0=sigma_x-sigma_z;
s=sigma00/sigma0;
#result
print('\nSince the calculated value of sigma0 = %g MPa, which is less than the yield strength of the aluminium alloy\nThus safety factor is = %g')%(sigma0,s);
```

In [4]:

```
from math import sqrt
#variable declaration
r_t=20;
p=1000;
#calculation
sigma1=p*r_t;
sigma1=sigma1/1000; #conversion to ksi
sigma=sqrt(3)*sigma1/2;
e=(sigma/25)**(1/0.25);
e1=sqrt(3)*e/2;
#result
print('\nPlastic Strain = %g')%(e1);
```