Inheritance
In Python, classes can inherit from other classes, allowing you to reuse code and create a hierarchy of classes. The parent class is known as the base class and the child class is known as the derived class.
Oppgave
Swipe to start coding
Try and experiment round with the GoldenRetriever
object!
Løsning
class GoldenRetriever(Dog):
def fetch(self):
print(f"{self.name} is fetching.")
GoldenRetriever('Fido', 'Golden Retriever').fetch()
Mark tasks as Completed
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 7
AVAILABLE TO ULTIMATE ONLY