16 lines
322 B
Python
16 lines
322 B
Python
import math
|
|
|
|
class
|
|
|
|
def circle_area(radius: float):
|
|
"""Calculate the area of a circle
|
|
|
|
:param radius: circle radius
|
|
:raises ValueError: radius is negative
|
|
:return: area of the circle
|
|
"""
|
|
if radius < 0:
|
|
raise ValueError("Circle can't have negative radius")
|
|
|
|
return math.pi * radius ** 2
|