11"""
2- The ideal gas law, also called the general gas equation, is the
3- equation of state of a hypothetical ideal gas. It is a good approximation
4- of the behavior of many gases under many conditions, although it has
5- several limitations. It was first stated by Benoît Paul Émile Clapeyron
6- in 1834 as a combination of the empirical Boyle's law, Charles's law,
7- Avogadro's law, and Gay-Lussac's law.[1] The ideal gas law is often written
8- in an empirical form:
9- ------------
10- | PV = nRT |
11- ------------
12- P = Pressure (Pa)
13- V = Volume (m^3)
14- n = Amount of substance (mol)
15- R = Universal gas constant
16- T = Absolute temperature (Kelvin)
17-
18- (Description adapted from https://en.wikipedia.org/wiki/Ideal_gas_law )
2+
3+ PV = nRT
4+
5+ Where, P = Pressure (Pa)
6+ V = Volume (m^3)
7+ n = Amount of substance (mol)
8+ R = Universal gas constant
9+ T = Absolute temperature (Kelvin)
10+
11+ Description adapted from https://en.wikipedia.org/wiki/Ideal_gas_law
12+
1913"""
2014
2115UNIVERSAL_GAS_CONSTANT = 8.314462 # Unit - J mol-1 K-1
@@ -32,9 +26,9 @@ def pressure_of_gas_system(moles: float, kelvin: float, volume: float) -> float:
3226 ...
3327 ValueError: Invalid inputs. Enter positive value.
3428 """
35- if moles < 0 or kelvin < 0 or volume < 0 :
29+ if moles <= 0 or kelvin <= 0 or volume <= 0 :
3630 raise ValueError ("Invalid inputs. Enter positive value." )
37- return moles * kelvin * UNIVERSAL_GAS_CONSTANT / volume
31+ return ( moles * kelvin * UNIVERSAL_GAS_CONSTANT ) / volume
3832
3933
4034def volume_of_gas_system (moles : float , kelvin : float , pressure : float ) -> float :
@@ -48,9 +42,9 @@ def volume_of_gas_system(moles: float, kelvin: float, pressure: float) -> float:
4842 ...
4943 ValueError: Invalid inputs. Enter positive value.
5044 """
51- if moles < 0 or kelvin < 0 or pressure < 0 :
45+ if moles <= 0 or kelvin <= 0 or pressure <= 0 :
5246 raise ValueError ("Invalid inputs. Enter positive value." )
53- return moles * kelvin * UNIVERSAL_GAS_CONSTANT / pressure
47+ return ( moles * kelvin * UNIVERSAL_GAS_CONSTANT ) / pressure
5448
5549
5650def temperature_of_gas_system (moles : float , volume : float , pressure : float ) -> float :
@@ -64,7 +58,7 @@ def temperature_of_gas_system(moles: float, volume: float, pressure: float) -> f
6458 ...
6559 ValueError: Invalid inputs. Enter positive value.
6660 """
67- if moles < 0 or volume < 0 or pressure < 0 :
61+ if moles <= 0 or volume <= 0 or pressure <= 0 :
6862 raise ValueError ("Invalid inputs. Enter positive value." )
6963
7064 return pressure * volume / (moles * UNIVERSAL_GAS_CONSTANT )
@@ -81,7 +75,7 @@ def moles_of_gas_system(kelvin: float, volume: float, pressure: float) -> float:
8175 ...
8276 ValueError: Invalid inputs. Enter positive value.
8377 """
84- if kelvin < 0 or volume < 0 or pressure < 0 :
78+ if kelvin <= 0 or volume <= 0 or pressure <= 0 :
8579 raise ValueError ("Invalid inputs. Enter positive value." )
8680
8781 return pressure * volume / (kelvin * UNIVERSAL_GAS_CONSTANT )
0 commit comments