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

Function volume_of_gas_system

physics/ideal_gas_law.py:40–53  ·  view source on GitHub ↗

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

(moles: float, kelvin: float, pressure: float)

Source from the content-addressed store, hash-verified

38
39
40def volume_of_gas_system(moles: float, kelvin: float, pressure: float) -> float:
41 """
42 >>> volume_of_gas_system(2, 100, 5)
43 332.57848
44 >>> volume_of_gas_system(0.5, 273, 0.004)
45 283731.01575
46 >>> volume_of_gas_system(3, -0.46, 23.5)
47 Traceback (most recent call last):
48 ...
49 ValueError: Invalid inputs. Enter positive value.
50 """
51 if moles < 0 or kelvin < 0 or pressure < 0:
52 raise ValueError("Invalid inputs. Enter positive value.")
53 return moles * kelvin * UNIVERSAL_GAS_CONSTANT / pressure
54
55
56def temperature_of_gas_system(moles: float, volume: float, pressure: float) -> float:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected