File tree Expand file tree Collapse file tree 1 file changed +1
-26
lines changed
Expand file tree Collapse file tree 1 file changed +1
-26
lines changed Original file line number Diff line number Diff line change 11from math import pi
22
3-
43def 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 ()
You can’t perform that action at this time.
0 commit comments