Spaces:
Running
on
Zero
Running
on
Zero
from dataclasses import dataclass | |
class Shape: | |
"""Base class for shapes""" | |
def area(self): | |
raise NotImplementedError | |
class Circle(Shape): | |
"""Circle shape""" | |
radius: float | |
def area(self): | |
"""Calculate the area of the circle""" | |
return 3.14 * (self.radius ** 2) | |
class Rectangle(Shape): | |
"""Rectangle shape""" | |
width: float | |
height: float | |
def area(self): | |
"""Calculate the area of the rectangle""" | |
return self.width * self.height |