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

Function pressure_of_gas_system

physics/ideal_gas_law.py:24–37  ·  view source on GitHub ↗

>>> pressure_of_gas_system(2, 100, 5) 332.57848 >>> pressure_of_gas_system(0.5, 273, 0.004) 283731.01575 >>> pressure_of_gas_system(3, -0.46, 23.5) Traceback (most recent call last): ... ValueError: Invalid inputs. Enter positive value.

(moles: float, kelvin: float, volume: float)

Source from the content-addressed store, hash-verified

22
23
24def pressure_of_gas_system(moles: float, kelvin: float, volume: float) -> float:
25 """
26 >>> pressure_of_gas_system(2, 100, 5)
27 332.57848
28 >>> pressure_of_gas_system(0.5, 273, 0.004)
29 283731.01575
30 >>> pressure_of_gas_system(3, -0.46, 23.5)
31 Traceback (most recent call last):
32 ...
33 ValueError: Invalid inputs. Enter positive value.
34 """
35 if moles < 0 or kelvin < 0 or volume < 0:
36 raise ValueError("Invalid inputs. Enter positive value.")
37 return moles * kelvin * UNIVERSAL_GAS_CONSTANT / volume
38
39
40def volume_of_gas_system(moles: float, kelvin: float, pressure: float) -> float:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected