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

Function first_molar_mass

physics/grahams_law.py:139–172  ·  view source on GitHub ↗

Input Parameters: ----------------- molar_mass: Molar mass of the first gas (g/mol, kg/kmol, etc.) effusion_rate_1: Effustion rate of first gas (m^2/s, mm^2/s, etc.) effusion_rate_2: Effustion rate of second gas (m^2/s, mm^2/s, etc.) Returns: -------- >>> first_mola

(
    molar_mass: float, effusion_rate_1: float, effusion_rate_2: float
)

Source from the content-addressed store, hash-verified

137
138
139def first_molar_mass(
140 molar_mass: float, effusion_rate_1: float, effusion_rate_2: float
141) -> float | ValueError:
142 """
143 Input Parameters:
144 -----------------
145 molar_mass: Molar mass of the first gas (g/mol, kg/kmol, etc.)
146 effusion_rate_1: Effustion rate of first gas (m^2/s, mm^2/s, etc.)
147 effusion_rate_2: Effustion rate of second gas (m^2/s, mm^2/s, etc.)
148
149 Returns:
150 --------
151 >>> first_molar_mass(2, 1.408943, 0.709752)
152 0.507524
153 >>> first_molar_mass(-1, 2.016, 4.002)
154 ValueError('Input Error: Molar mass and effusion rate values must greater than 0.')
155 >>> first_molar_mass(1)
156 Traceback (most recent call last):
157 ...
158 TypeError: first_molar_mass() missing 2 required positional arguments: \
159'effusion_rate_1' and 'effusion_rate_2'
160 >>> first_molar_mass(1, 2.016)
161 Traceback (most recent call last):
162 ...
163 TypeError: first_molar_mass() missing 1 required positional argument: \
164'effusion_rate_2'
165 """
166 return (
167 round(molar_mass / pow(effusion_rate_1 / effusion_rate_2, 2), 6)
168 if validate(molar_mass, effusion_rate_1, effusion_rate_2)
169 else ValueError(
170 "Input Error: Molar mass and effusion rate values must greater than 0."
171 )
172 )
173
174
175def second_molar_mass(

Callers

nothing calls this directly

Calls 1

validateFunction · 0.70

Tested by

no test coverage detected