IniziaInizia gratis

Understanding inheritance

Inheritance is a powerful tool of object-oriented languages that allows you to customize the functionality of existing classes without having to re-implement methods from scratch.

In this exercise, you'll check your understanding of inheritance. The questions refer to the following two classes:

class Counter:
    def __init__(self, count):
       self.count = count

    def add_counts(self, n):
       self.count += n

class Indexer(Counter):
    pass

Questo esercizio fa parte del corso

Introduction to Object-Oriented Programming in Python

Visualizza il corso

Esercizio pratico interattivo

Passa dalla teoria alla pratica con uno dei nostri esercizi interattivi

Inizia esercizio