I’ve been working on an Aerodynamics calculator using python (which I’m relatively new at), In this program, a value can be calculated based on multiple different inputs *ie. a calculates b, b calculates c, or c can find b and b can find a*.

To elaborate on the function of this program it will loop through it’s logic until it has found all the things it could with the given input(s). The code is pretty long for it’s function and that’s why I’d like to see if it could be optimized or if I could do anything better. For the input method, the input is a string. The code is as follows:

```
def Find_Pressure(temp):
pressure = (101.29 * (((temp + 273.1) / 288.08) ** 5.256))
return pressure
def Find_Temp_Alt(alt, ground_temp):
Temp = ground_temp - (0.00649 * alt)
return Temp
def Find_Density(pressure, temp):
density = (pressure / (0.2869 * (temp + 273.1)))
return density
def Find_Alt_Temp(temp, ground_temp):
Alt = ((ground_temp - temp) / 0.00649)
return Alt
def is_Valid(x):
try:
float(x)
return True
except ValueError:
return False
def Parser(ground_temp, temp, alt, pressure, density):
a = t = p = d = False
run = True
Alt = Temp = Pressure = Density = "N/A"
if is_Valid(alt):
Alt = float(alt)
a = True
if is_Valid(temp):
Temp = float(temp)
if Temp <= -273.1:
t = False
else:
t = True
if is_Valid(pressure):
Pressure = float(pressure)
p = True
if is_Valid(density):
Density = float(density)
d = True
if not is_Valid(ground_temp):
print('Enter Ground Temp')
else:
G_T = float(ground_temp)
while run:
run = False
if a and not t:
Temp = Find_Temp_Alt(Alt, G_T)
t = True
run = True
if t and not a:
Alt = Find_Alt_Temp(Temp, G_T)
a = True
run = True
if p and not t:
Temp = ((288.08 * ((Pressure / 101.29) ** (1 / 5.256))) - 273.1)
t = True
run = True
if t and not p:
Pressure = Find_Pressure(Temp)
p = True
run = True
if (p and t) and not d:
Density = Find_Density(Pressure, Temp)
d = True
run = True
if (d and t) and not p:
Pressure = (Density * 0.2869 * (Temp + 273.1))
p = True
run = True
if (d and p) and not t:
Temp = ((Pressure / Density * 0.2869) - 273.1)
t = True
run = True
return Alt, Temp, Pressure, Density
```

I apricate any help/feedback, thanks in advance!