Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Challenge | Inheritance
Object-Oriented Programming in Python
course content

Kursinhalt

Object-Oriented Programming in Python

Object-Oriented Programming in Python

1. Classes and Objects
2. Encapsulation
3. Inheritance
4. Polymorphism

book
Challenge

Note

Private methods and attributes of the parent class are not available in the child's class.

The Animal class:

1234567
class Animal: def __init__(self, name = None, age = None): self.__name = name self.__age = age def move(self): print('Animal is moving...')
copy
Aufgabe

Swipe to start coding

  1. Create a class Cat that inherits the Animal class.
  2. Create the eat method.
  3. Create a 5 kg 10 years old 'Lola' cat.
  4. Move the cat (using the move() method from the Animal class).
  5. 'Feed' the cat (using the eat() method from the Cat class).

Lösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 3. Kapitel 2
toggle bottom row

book
Challenge

Note

Private methods and attributes of the parent class are not available in the child's class.

The Animal class:

1234567
class Animal: def __init__(self, name = None, age = None): self.__name = name self.__age = age def move(self): print('Animal is moving...')
copy
Aufgabe

Swipe to start coding

  1. Create a class Cat that inherits the Animal class.
  2. Create the eat method.
  3. Create a 5 kg 10 years old 'Lola' cat.
  4. Move the cat (using the move() method from the Animal class).
  5. 'Feed' the cat (using the eat() method from the Cat class).

Lösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 3. Kapitel 2
Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
Wir sind enttäuscht, dass etwas schief gelaufen ist. Was ist passiert?
some-alt