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

Contenu du cours

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

Tâche

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.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 4. Chapitre 7
toggle bottom row

book
Challenge: AbstractAdmin

Tâche

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.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 4. Chapitre 7
Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
We're sorry to hear that something went wrong. What happened?
some-alt