Skip to content

Commit af54e71

Browse files
authored
Fix arc_length.py: Complete docstring, add error handling, and add main block
1 parent c52813d commit af54e71

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

maths/arc_length.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,18 @@ def arc_length(angle: float, radius: float) -> float:
2828
>>> arc_length(-90, 10)
2929
Traceback (most recent call last):
3030
...
31+
ValueError: angle and radius must be positive
32+
>>> arc_length(90, -10)
33+
Traceback (most recent call last):
34+
...
35+
ValueError: angle and radius must be positive
36+
"""
37+
if angle < 0 or radius < 0:
38+
raise ValueError("angle and radius must be positive")
39+
return 2 * pi * radius * (angle / 360)
40+
41+
42+
if __name__ == "__main__":
43+
import doctest
44+
45+
doctest.testmod()

0 commit comments

Comments
 (0)