Skip to content

Commit 2a31245

Browse files
committed
doctest and type hints
1 parent 3b86444 commit 2a31245

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Diff for: physics/grahams_law.py

+24-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,27 @@
1717
from math import pow, sqrt
1818

1919

20-
def validate(*values) -> bool:
20+
def validate(*values: float) -> bool:
21+
"""
22+
Input Parameters:
23+
-----------------
24+
effusion_rate_1: Effustion rate of first gas (m^2/s, mm^2/s, etc.)
25+
effusion_rate_2: Effustion rate of second gas (m^2/s, mm^2/s, etc.)
26+
molar_mass_1: Molar mass of the first gas (g/mol, kg/kmol, etc.)
27+
molar_mass_2: Molar mass of the second gas (g/mol, kg/kmol, etc.)
28+
29+
Returns:
30+
--------
31+
>>> validate(2.016, 4.002)
32+
True
33+
>>> validate(-2.016, 4.002)
34+
Traceback (most recent call last):
35+
...
36+
ValueError: Invalid inputs. Effusion rates and molar masses must be a positive
37+
value.
38+
>>> validate()
39+
False
40+
"""
2141
for value in values:
2242
if value >= 0.0:
2343
return True
@@ -189,3 +209,6 @@ def second_molar_mass(
189209
"""
190210
validate(molar_mass, effusion_rate_1, effusion_rate_2)
191211
return round(pow(effusion_rate_1 / effusion_rate_2, 2) / molar_mass, 6)
212+
213+
214+
print(validate())

0 commit comments

Comments
 (0)