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

Function area_circle

maths/area.py:435–452  ·  view source on GitHub ↗

Calculate the area of a circle. >>> area_circle(20) 1256.6370614359173 >>> area_circle(1.6) 8.042477193189871 >>> area_circle(0) 0.0 >>> area_circle(-1) Traceback (most recent call last): ... ValueError: area_circle() only accepts non-neg

(radius: float)

Source from the content-addressed store, hash-verified

433
434
435def area_circle(radius: float) -> float:
436 """
437 Calculate the area of a circle.
438
439 >>> area_circle(20)
440 1256.6370614359173
441 >>> area_circle(1.6)
442 8.042477193189871
443 >>> area_circle(0)
444 0.0
445 >>> area_circle(-1)
446 Traceback (most recent call last):
447 ...
448 ValueError: area_circle() only accepts non-negative values
449 """
450 if radius < 0:
451 raise ValueError("area_circle() only accepts non-negative values")
452 return pi * radius**2
453
454
455def area_ellipse(radius_x: float, radius_y: float) -> float:

Callers 1

area.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected