MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / moles_of_gas_system

Function moles_of_gas_system

physics/ideal_gas_law.py:73–87  ·  view source on GitHub ↗

>>> moles_of_gas_system(100, 5, 10) 0.06013618199229246 >>> moles_of_gas_system(110, 5009, 1000) 5476.766101807144 >>> moles_of_gas_system(3, -0.46, 23.5) Traceback (most recent call last): ... ValueError: Invalid inputs. Enter positive value.

(kelvin: float, volume: float, pressure: float)

Source from the content-addressed store, hash-verified

71
72
73def moles_of_gas_system(kelvin: float, volume: float, pressure: float) -> float:
74 """
75 >>> moles_of_gas_system(100, 5, 10)
76 0.06013618199229246
77 >>> moles_of_gas_system(110, 5009, 1000)
78 5476.766101807144
79 >>> moles_of_gas_system(3, -0.46, 23.5)
80 Traceback (most recent call last):
81 ...
82 ValueError: Invalid inputs. Enter positive value.
83 """
84 if kelvin < 0 or volume < 0 or pressure < 0:
85 raise ValueError("Invalid inputs. Enter positive value.")
86
87 return pressure * volume / (kelvin * UNIVERSAL_GAS_CONSTANT)
88
89
90if __name__ == "__main__":

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected