Compare commits

...

5 Commits

Author SHA1 Message Date
robertjcalistri
5ce54f2180
Update ideal_gas_law.py
Updated incorrect function calls moles of gas system doctests
2023-08-03 08:15:55 -04:00
robertjcalistri
b637591ae9
Update physics/ideal_gas_law.py
Removed unnecessary parentheses

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-08-03 08:13:29 -04:00
robertjcalistri
c8c29e9611
Update physics/ideal_gas_law.py
Removed unnecessary parentheses

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-08-03 08:13:13 -04:00
robertjcalistri
a2d6d5b574
Update physics/ideal_gas_law.py
Updated formatting

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-08-03 08:12:55 -04:00
robertjcalistri
2beb2071ce
Update physics/ideal_gas_law.py
Renamed function name

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-08-03 08:11:16 -04:00

View File

@ -57,7 +57,7 @@ def temperature_of_gas_system(moles: float, volume: float, pressure: float) -> f
"""
>>> temperature_of_gas_system(2, 100, 5)
30.068090996146232
>>> temperature_of_gas_system(11,5009,1000)
>>> temperature_of_gas_system(11, 5009, 1000)
54767.66101807144
>>> temperature_of_gas_system(3, -0.46, 23.5)
Traceback (most recent call last):
@ -67,16 +67,16 @@ def temperature_of_gas_system(moles: float, volume: float, pressure: float) -> f
if moles < 0 or volume < 0 or pressure < 0:
raise ValueError("Invalid inputs. Enter positive value.")
return (pressure * volume) / (moles * UNIVERSAL_GAS_CONSTANT)
return pressure * volume / (moles * UNIVERSAL_GAS_CONSTANT)
def num_moles_of_gas_in_system(kelvin: float, volume: float, pressure: float) -> float:
def moles_of_gas_system(kelvin: float, volume: float, pressure: float) -> float:
"""
>>> temperature_of_gas_system(100, 5, 10)
>>> moles_of_gas_system(100, 5, 10)
0.06013618199229246
>>> temperature_of_gas_system(110,5009,1000)
>>> moles_of_gas_system(110,5009,1000)
5476.766101807144
>>> temperature_of_gas_system(3, -0.46, 23.5)
>>> moles_of_gas_system(3, -0.46, 23.5)
Traceback (most recent call last):
...
ValueError: Invalid inputs. Enter positive value.
@ -84,7 +84,7 @@ def num_moles_of_gas_in_system(kelvin: float, volume: float, pressure: float) ->
if kelvin < 0 or volume < 0 or pressure < 0:
raise ValueError("Invalid inputs. Enter positive value.")
return (pressure * volume) / (kelvin * UNIVERSAL_GAS_CONSTANT)
return pressure * volume / (kelvin * UNIVERSAL_GAS_CONSTANT)
if __name__ == "__main__":