Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Challenge: AbstractAdmin | Polymorphism and Abstraction
In-Depth Python OOP
course content

Kursinhalt

In-Depth Python OOP

In-Depth Python OOP

1. OOP Concepts
2. Inheritance
3. Encapsulation
4. Polymorphism and Abstraction
5. Magic Methods

book
Challenge: AbstractAdmin

Aufgabe

Swipe to start coding

Let's protect your Admin class structure! You need to define the AbstractAdmin class that should have the strict Admin class structure.

  1. Import the ABC class and abstractmethod decorator from the abc package.
  2. Define the AbstractAdmin class inherited from the ABC class.
  3. Define the abstract methods login(), logout(), create_content(), update_content(), and delete_content() via the @abstractmethod decorator.
    Use the pass keyword to miss the function implementation.
  4. Inherit the Admin class from the AbstractAdmin class.
  5. Try to run the code with comments. Look at the Traceback.
  6. Delete comments in the Admin class and run the code again.

Note

Abstract methods should not receive arguments.

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 4. Kapitel 7
toggle bottom row

book
Challenge: AbstractAdmin

Aufgabe

Swipe to start coding

Let's protect your Admin class structure! You need to define the AbstractAdmin class that should have the strict Admin class structure.

  1. Import the ABC class and abstractmethod decorator from the abc package.
  2. Define the AbstractAdmin class inherited from the ABC class.
  3. Define the abstract methods login(), logout(), create_content(), update_content(), and delete_content() via the @abstractmethod decorator.
    Use the pass keyword to miss the function implementation.
  4. Inherit the Admin class from the AbstractAdmin class.
  5. Try to run the code with comments. Look at the Traceback.
  6. Delete comments in the Admin class and run the code again.

Note

Abstract methods should not receive arguments.

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 4. Kapitel 7
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
We're sorry to hear that something went wrong. What happened?
some-alt