File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -186,6 +186,32 @@ def area_circle(radius: float) -> float:
186186 return pi * radius ** 2
187187
188188
189+ def area_ellipse (radius_x : float , radius_y : float ) -> float :
190+ """
191+ Calculate the area of a ellipse
192+
193+ >>> area_ellipse(10, 10)
194+ 314.1592653589793
195+ >>> area_ellipse(10, 20)
196+ 628.3185307179587
197+ >>> area_ellipse(-10, 20)
198+ Traceback (most recent call last):
199+ ...
200+ ValueError: area_ellipse() only accepts non-negative values
201+ >>> area_ellipse(10, -20)
202+ Traceback (most recent call last):
203+ ...
204+ ValueError: area_ellipse() only accepts non-negative values
205+ >>> area_ellipse(-10, -20)
206+ Traceback (most recent call last):
207+ ...
208+ ValueError: area_ellipse() only accepts non-negative values
209+ """
210+ if radius_x < 0 or radius_y < 0 :
211+ raise ValueError ("area_ellipse() only accepts non-negative values" )
212+ return pi * radius_x * radius_y
213+
214+
189215def area_rhombus (diagonal_1 : float , diagonal_2 : float ) -> float :
190216 """
191217 Calculate the area of a rhombus
You can’t perform that action at this time.
0 commit comments