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

Function temperature_of_gas_system

physics/ideal_gas_law.py:56–70  ·  view source on GitHub ↗

>>> temperature_of_gas_system(2, 100, 5) 30.068090996146232 >>> temperature_of_gas_system(11, 5009, 1000) 54767.66101807144 >>> temperature_of_gas_system(3, -0.46, 23.5) Traceback (most recent call last): ... ValueError: Invalid inputs. Enter positive value.

(moles: float, volume: float, pressure: float)

Source from the content-addressed store, hash-verified

54
55
56def temperature_of_gas_system(moles: float, volume: float, pressure: float) -> float:
57 """
58 >>> temperature_of_gas_system(2, 100, 5)
59 30.068090996146232
60 >>> temperature_of_gas_system(11, 5009, 1000)
61 54767.66101807144
62 >>> temperature_of_gas_system(3, -0.46, 23.5)
63 Traceback (most recent call last):
64 ...
65 ValueError: Invalid inputs. Enter positive value.
66 """
67 if moles < 0 or volume < 0 or pressure < 0:
68 raise ValueError("Invalid inputs. Enter positive value.")
69
70 return pressure * volume / (moles * UNIVERSAL_GAS_CONSTANT)
71
72
73def moles_of_gas_system(kelvin: float, volume: float, pressure: float) -> float:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected