Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele 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.

Tehtävä

Swipe to start coding

Try and experiment round with the GoldenRetriever object!

Ratkaisu

class GoldenRetriever(Dog):
def fetch(self):
print(f"{self.name} is fetching.")

GoldenRetriever('Fido', 'Golden Retriever').fetch()

Mark tasks as Completed
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 7
AVAILABLE TO ULTIMATE ONLY
We use cookies to make your experience better!
some-alt