抽象クラスを作成しサブクラスで具体的なメソッドを定義し実装してみます。 ■今回の環境(Python) 今回のPythonは、バージョン3.9.16を用いる。(なお、Google Colaboratory(Google Colab)を使用。) ■抽象クラスを作成しサブクラスで具体的なメソッドの定義 では、早速抽象クラスを作成しサブクラスで具体的なメソッドを定義し実装するために、コードを書いていきます。 ■コード class Vehicle: def __init__(self, brand, color): self.brand = brand self.color = color def drive(self): raise NotImplementedError("Subclasses must implement the drive method.") class Car(Vehicl
![抽象クラスを作成しサブクラスで具体的なメソッドを定義し実装する](https://cdn-ak-scissors.b.st-hatena.com/image/square/b0e6c97966e87a40b9ffc727d8131acbff631a61/height=288;version=1;width=512/https%3A%2F%2Flaboratory.kazuuu.net%2Fwp-content%2Fuploads%2F2021%2F07%2FL.png)