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

Aufgabe

Swipe to start coding

You have a User class from the last challenge.
The methods are corrected (User -> {self.username} in strings).
Let's define the Admin class!

  1. Define the Admin class inherited from the User class.
  2. Define the create_content() admin's method that prints the string:
    f"{self.username} creates the content".
  3. Define the update_content() admin's method that prints the string:
    f"{self.username} updates the content".
  4. Define the delete_content() admin's method that prints the string:
    f"{self.username} deletes the content".

Note

Admin has all the capabilities of User that do not need to be reimplemented. This is an example of how inheritance makes our life easier.

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

book
Challenge: Admin

Aufgabe

Swipe to start coding

You have a User class from the last challenge.
The methods are corrected (User -> {self.username} in strings).
Let's define the Admin class!

  1. Define the Admin class inherited from the User class.
  2. Define the create_content() admin's method that prints the string:
    f"{self.username} creates the content".
  3. Define the update_content() admin's method that prints the string:
    f"{self.username} updates the content".
  4. Define the delete_content() admin's method that prints the string:
    f"{self.username} deletes the content".

Note

Admin has all the capabilities of User that do not need to be reimplemented. This is an example of how inheritance makes our life easier.

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