Skip to content

Commit c52813d

Browse files
authored
Fix doctest expected value for arc_length(45.5, 10.5)
1 parent 31b04af commit c52813d

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

maths/arc_length.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
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.
7-
86
The arc length is the distance along the curved line making up the arc.
97
Formula: arc_length = 2 * pi * radius * (angle / 360)
10-
118
Wikipedia: https://en.wikipedia.org/wiki/Arc_length
12-
139
Args:
1410
angle: The angle in degrees
1511
radius: The radius of the circle
16-
1712
Returns:
1813
The arc length as a float
19-
2014
>>> arc_length(45, 5)
2115
3.9269908169872414
2216
>>> arc_length(120, 15)
@@ -30,26 +24,7 @@ def arc_length(angle: float, radius: float) -> float:
3024
>>> arc_length(180, 10)
3125
31.41592653589793
3226
>>> arc_length(45.5, 10.5)
33-
8.329618601250994
27+
8.33831050140291
3428
>>> arc_length(-90, 10)
3529
Traceback (most recent call last):
3630
...
37-
ValueError: arc_length() only accepts non-negative values
38-
>>> arc_length(90, -10)
39-
Traceback (most recent call last):
40-
...
41-
ValueError: arc_length() only accepts non-negative values
42-
>>> arc_length(-45, -5)
43-
Traceback (most recent call last):
44-
...
45-
ValueError: arc_length() only accepts non-negative values
46-
"""
47-
if angle < 0 or radius < 0:
48-
raise ValueError("arc_length() only accepts non-negative values")
49-
return 2 * pi * radius * (angle / 360)
50-
51-
52-
if __name__ == "__main__":
53-
import doctest
54-
55-
doctest.testmod()

0 commit comments

Comments
 (0)