Skip to content

Instantly share code, notes, and snippets.

@bamaham93
Created April 28, 2024 21:34
Show Gist options
  • Save bamaham93/e76ced83e7526e2a7ef2ce0dec0e566f to your computer and use it in GitHub Desktop.
Save bamaham93/e76ced83e7526e2a7ef2ce0dec0e566f to your computer and use it in GitHub Desktop.
"""
"""
import math
def convert_f_to_k(f: float) -> float:
"""
Calculates the conversion from degrees Farenheit to degrees Kelvin.
Kelvin = ((Fahrenheit - 32) / 1.8) + 273.15
"""
k = ((f -32) /1.8 ) + 273.15
return k
def o2_calc(t1, t2, p1):
"""
t1: Initial bottle temp, in *F
t2: End bottle temp, in *F
p1: Initial bottle pressure, in PSI
Returns P2: Expected pressure
"""
atmosphere_pressure = 14.06 # Assumes sea level
t1_abs = convert_f_to_k(t1)
t2_abs = convert_f_to_k(t2)
p2 = t2_abs / t1_abs * ( p1)
return format(p2, '.2f')
if __name__ == '__main__':
t1 = float(input("Enter the inital temp: "))
t2 = float(input("Enter the end temp: "))
p1 = float(input("Enter the start pressure: "))
print(o2_calc(t1, t2, p1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment