+1 vote
in Python by
How do you define abstract classes in Python?

1 Answer

0 votes
by

You define an abstract class by inheriting the ABC class from the abc module:

from abc import ABC

class AbstractCar(ABC):

    @abstractmethod

    def drive(self):

        pass

To implement the class, just inherit it:

class ToyotaSupra(AbstractCar):

    def drive(self):

        print('brrrr sutututu')

Related questions

0 votes
asked Sep 5, 2021 in Python by SakshiSharma
0 votes
asked May 23, 2020 in Python by sharadyadav1986
...