同步操作将从 编程语言算法集/Python 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
"""The ideal gas law, also called the general gas equation, is theequation of state of a hypothetical ideal gas. It is a good approximationof the behavior of many gases under many conditions, although it hasseveral limitations. It was first stated by Benoît Paul Émile Clapeyronin 1834 as a combination of the empirical Boyle's law, Charles's law,Avogadro's law, and Gay-Lussac's law.[1] The ideal gas law is often writtenin an empirical form:------------| PV = nRT |------------P = Pressure (Pa)V = Volume (m^3)n = Amount of substance (mol)R = Universal gas constantT = Absolute temperature (Kelvin)(Description adapted from https://en.wikipedia.org/wiki/Ideal_gas_law )"""UNIVERSAL_GAS_CONSTANT = 8.314462 # Unit - J mol-1 K-1def pressure_of_gas_system(moles: float, kelvin: float, volume: float) -> float:""">>> 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."""if moles < 0 or kelvin < 0 or volume < 0:raise ValueError("Invalid inputs. Enter positive value.")return moles * kelvin * UNIVERSAL_GAS_CONSTANT / volumedef volume_of_gas_system(moles: float, kelvin: float, pressure: float) -> float:""">>> 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."""if moles < 0 or kelvin < 0 or pressure < 0:raise ValueError("Invalid inputs. Enter positive value.")return moles * kelvin * UNIVERSAL_GAS_CONSTANT / pressuredef temperature_of_gas_system(moles: float, volume: float, pressure: float) -> float:""">>> 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."""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:""">>> 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."""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 testmodtestmod()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。