Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Inheritance | Best Practices: Python OOP
Best Practices: Python OOP

book
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?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 7
AVAILABLE TO ULTIMATE ONLY
some-alt