from __future__ import division
import math
#Initializing the variables
rho0 = 1.8;
R = 287;
T = 75+273; # Temperature in kelvin
gma = 1.4;
Ma = 0.7;
#Calculations
P0 = rho0*R*T;
c = (gma*R*T)**0.5;
V0 = Ma*c;
Pt = (P0**((gma-1)/gma) + rho0*((gma-1)/gma)*(V0**2/(2*P0**(1/gma))))**(gma/(gma-1));
rhoT = rho0*(Pt/P0)**(1/gma);
Tt = Pt/(R*rhoT)-273;
print "Staganation Pressure (kN/m2 ) :",round(Pt/1000,1)
print "Temperature (Degree Celcius) :",round(Tt,1)
print "Density of airstream (kg/m3) :",round(rhoT,3)
from __future__ import division
import math
#Initializing the variables
R = 287;
T = 28+273;
gma = 1.4;
P = 1.02*10**5;
rhoHg = 13.6*10**3;
g = 9.81;
#Calculations
#Case(a)
U0 = 50;
c = (gma*R*T)**0.5;
Ma = U0/c;
rho = P/(R*T);
DelP = 0.5*rho*U0**2; #Pt-P
ha = DelP/(rhoHg*g);
#Case(b)
U0 = 250;
Ma = U0/c;
Pt = P*(1+(gma-1)*Ma**2/2)**(gma/(gma-1));
DelP = Pt-P
hb = DelP/(rhoHg*g);
#Case (c)
U0 = 420;
Ma1 =U0/c;
P2 = P*((2*gma/(gma+1))*Ma1**2 - ((gma-1)/(gma+1)));
N = Ma1**2 +2/(gma-1); # Numerator
D = 2*gma*Ma1**2/(gma-1)-1;
Ma2 = (N/D)**0.5;
Pt2 = P2*(1+(gma-1)*Ma2**2/2)**(gma/(gma-1));
hc = (Pt2-P2)/(rhoHg*g) ;
print "Difference in height of mercury column in case (a) in mm :",round(ha*1000,2)
print "Difference in height of mercury column in case (b) in mm :",round(hb*1000,1)
print "Difference in height of mercury column in case (c) in mm :",round(hc*1000,0)