Skip to content

Commit 9aba612

Browse files
authored
Restore complete file with correct doctest value and error handling
1 parent a9006a4 commit 9aba612

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

maths/arc_length.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
from math import pi
22

3-
43
def arc_length(angle: float, radius: float) -> float:
54
"""
65
Calculate the arc length of a circle.
6+
77
The arc length is the distance along the curved line making up the arc.
88
Formula: arc_length = 2 * pi * radius * (angle / 360)
99
Wikipedia: https://en.wikipedia.org/wiki/Arc_length
10+
1011
Args:
1112
angle: The angle in degrees
1213
radius: The radius of the circle
14+
1315
Returns:
1416
The arc length as a float
17+
1518
>>> arc_length(45, 5)
1619
3.9269908169872414
1720
>>> arc_length(120, 15)
@@ -39,8 +42,6 @@ def arc_length(angle: float, radius: float) -> float:
3942
raise ValueError("angle and radius must be positive")
4043
return 2 * pi * radius * (angle / 360)
4144

42-
4345
if __name__ == "__main__":
4446
import doctest
45-
4647
doctest.testmod()

0 commit comments

Comments
 (0)