Learn Python ABSTRACT CLASSES in 7 minutes! 👻
# Abstract class: A class that cannot be instantiated on its own; Meant to be subclassed. # They can contain abstract methods, which are decl...
🔥 Related Trending Topics
LIVE TRENDSThis video may be related to current global trending topics. Click any trend to explore more videos about what's hot right now!
THIS VIDEO IS TRENDING!
This video is currently trending in Thailand under the topic 'สภาพอากาศ'.
About this video
# Abstract class: A class that cannot be instantiated on its own; Meant to be subclassed.
# They can contain abstract methods, which are declared but have no implementation.
# Abstract classes benefits:
# 1. Prevents instantiation of the class itself
# 2. Requires children to use inherited abstract methods
from abc import ABC, abstractmethod
class Vehicle(ABC):
@abstractmethod
def go(self):
pass
@abstractmethod
def stop(self):
pass
class Car(Vehicle):
def go(self):
print("You drive the car")
def stop(self):
print("You stop the car")
class Motorcycle(Vehicle):
def go(self):
print("You ride the motorcycle")
def stop(self):
print("You stop the motorcycle")
class Boat(Vehicle):
def go(self):
print("You sail the boat")
def stop(self):
print("You anchor the boat")
car = Car()
motorcycle = Motorcycle()
boat = Boat()
Video Information
Views
35.8K
Total views since publication
Likes
1.0K
User likes and reactions
Duration
7:02
Video length
Published
Jun 13, 2024
Release date
Quality
hd
Video definition
About the Channel
Tags and Topics
This video is tagged with the following topics. Click any tag to explore more related content and discover similar videos:
#Python tutorial #python course #python programming #python abstract #python abstract classes #abstract classes #abstract methods
Tags help categorize content and make it easier to find related videos. Browse our collection to discover more content in these categories.