MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / area_ellipse

Function area_ellipse

maths/area.py:455–482  ·  view source on GitHub ↗

Calculate the area of a ellipse. >>> area_ellipse(10, 10) 314.1592653589793 >>> area_ellipse(10, 20) 628.3185307179587 >>> area_ellipse(0, 0) 0.0 >>> area_ellipse(1.6, 2.6) 13.06902543893354 >>> area_ellipse(-10, 20) Traceback (most recent ca

(radius_x: float, radius_y: float)

Source from the content-addressed store, hash-verified

453
454
455def area_ellipse(radius_x: float, radius_y: float) -> float:
456 """
457 Calculate the area of a ellipse.
458
459 >>> area_ellipse(10, 10)
460 314.1592653589793
461 >>> area_ellipse(10, 20)
462 628.3185307179587
463 >>> area_ellipse(0, 0)
464 0.0
465 >>> area_ellipse(1.6, 2.6)
466 13.06902543893354
467 >>> area_ellipse(-10, 20)
468 Traceback (most recent call last):
469 ...
470 ValueError: area_ellipse() only accepts non-negative values
471 >>> area_ellipse(10, -20)
472 Traceback (most recent call last):
473 ...
474 ValueError: area_ellipse() only accepts non-negative values
475 >>> area_ellipse(-10, -20)
476 Traceback (most recent call last):
477 ...
478 ValueError: area_ellipse() only accepts non-negative values
479 """
480 if radius_x < 0 or radius_y < 0:
481 raise ValueError("area_ellipse() only accepts non-negative values")
482 return pi * radius_x * radius_y
483
484
485def area_rhombus(diagonal_1: float, diagonal_2: float) -> float:

Callers 1

area.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected