Create a base class and subclasses that override methods. Use polymorphism to call area() on any shape.
Step 1 of 100%
Step 1 of 10
Define a class Shape that inherits from ABC (already imported from abc)
pythonLn 1, Col 1
1
2
3
4
5
6
7
8
9
import math
from abc import ABC, abstractmethod
# Build a shape hierarchy from scratch## Requirements:# - Shape(ABC): abstract base class with @abstractmethod area(self)# - Rectangle(Shape): __init__(self, width, height), area returns width * height# - Circle(Shape): __init__(self, radius), area returns math.pi * radius ** 2