the ideal gas law also called the general gas equation is the equation of state of a hypothetical ideal gas it is a good approximation of the behavior of many gases under many conditions although it has several limitations it was first stated by benot paul mile clapeyron in 1834 as a combination of the empirical boyle s law charles s law avogadro s law and gaylussac s law 1 the ideal gas law is often written in an empirical form pv nrt p pressure pa v volume m3 n amount of substance mol r universal gas constant t absolute temperature kelvin description adapted from https en wikipedia orgwikiidealgaslaw pressureofgassystem2 100 5 332 57848 pressureofgassystem0 5 273 0 004 283731 01575 pressureofgassystem3 0 46 23 5 traceback most recent call last valueerror invalid inputs enter positive value volumeofgassystem2 100 5 332 57848 volumeofgassystem0 5 273 0 004 283731 01575 volumeofgassystem3 0 46 23 5 traceback most recent call last valueerror invalid inputs enter positive value temperatureofgassystem2 100 5 30 068090996146232 temperatureofgassystem11 5009 1000 54767 66101807144 temperatureofgassystem3 0 46 23 5 traceback most recent call last valueerror invalid inputs enter positive value molesofgassystem100 5 10 0 06013618199229246 molesofgassystem110 5009 1000 5476 766101807144 molesofgassystem3 0 46 23 5 traceback most recent call last valueerror invalid inputs enter positive value unit j mol 1 k 1 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 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 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_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
UNIVERSAL_GAS_CONSTANT = 8.314462  


def pressure_of_gas_system(moles: float, kelvin: float, volume: float) -> float:
    
    if moles < 0 or kelvin < 0 or volume < 0:
        raise ValueError("Invalid inputs. Enter positive value.")
    return moles * kelvin * UNIVERSAL_GAS_CONSTANT / volume


def volume_of_gas_system(moles: float, kelvin: float, pressure: float) -> float:
    
    if moles < 0 or kelvin < 0 or pressure < 0:
        raise ValueError("Invalid inputs. Enter positive value.")
    return moles * kelvin * UNIVERSAL_GAS_CONSTANT / pressure


def temperature_of_gas_system(moles: float, volume: float, pressure: float) -> float:
    
    if moles < 0 or volume < 0 or pressure < 0:
        raise ValueError("Invalid inputs. Enter positive value.")

    return pressure * volume / (moles * UNIVERSAL_GAS_CONSTANT)


def moles_of_gas_system(kelvin: float, volume: float, pressure: float) -> float:
    
    if kelvin < 0 or volume < 0 or pressure < 0:
        raise ValueError("Invalid inputs. Enter positive value.")

    return pressure * volume / (kelvin * UNIVERSAL_GAS_CONSTANT)


if __name__ == "__main__":
    from doctest import testmod

    testmod()