Course Content
In-Depth Python OOP
In-Depth Python OOP
4. Polymorphism and Abstraction
Challenge: User Auth
Task
Swipe to show code editor
Let's improve your User
class!
- Create the class attribute
is_authenticated
in theUser
class. - Define the
login()
method that takes argumentsself
andtaken_password
. - The
login()
method should compare the user and taken passwords.
If the user password is equal to the taken password, theTrue
should be assigned to theis_authenticated
attribute.
If the user password is not equal to the taken password, the"Wrong password!"
should be written in the console. - Define the
logout()
methods. This method should assign theFalse
value to theis_authenticated
instance attribute.
Solution
Switch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?
Thanks for your feedback!
Section 1. Chapter 8
Challenge: User Auth
Task
Swipe to show code editor
Let's improve your User
class!
- Create the class attribute
is_authenticated
in theUser
class. - Define the
login()
method that takes argumentsself
andtaken_password
. - The
login()
method should compare the user and taken passwords.
If the user password is equal to the taken password, theTrue
should be assigned to theis_authenticated
attribute.
If the user password is not equal to the taken password, the"Wrong password!"
should be written in the console. - Define the
logout()
methods. This method should assign theFalse
value to theis_authenticated
instance attribute.
Solution
Switch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?
Thanks for your feedback!
Section 1. Chapter 8
Switch to desktop for real-world practiceContinue from where you are using one of the options below