1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Object-Oriented Programming in Python

Connected

Exercise

Implementing a formal interface with ABC

In this exercise, you'll practice implementing a formal interface created using the ABC class and the @abstractmethod decorator. The Business interface has been created for you, and is shown below. Good luck!

class Business(ABC):
  @abstractmethod
  def sell_product(self, product_name, price, quantity):
    pass

Instructions 1/2

undefined XP
    1
    2
  • Create a Bakery class that implements the Business interface; do not yet define the sell_product() method.
  • Attempt to create an instance of the Bakery class in a try-except block; observe the exception that is thrown.