1.12 Lab: Check Login Credentials (classes) Complete the Login class implementation. For the class method check_credenti
Posted: Mon Jun 06, 2022 4:52 pm
1.12 Lab: Check Login Credentials (classes)
Complete the Login class
implementation. For the class method check_credentials(), you will
need to
accept two arguments - login and passwd. Do not forget about the
self argument.
This class method will set two local variables simlogin =
"Test" and simpass = "test1234".
These variables will simulate the correct login and password for
the credential check process.
The method will receive the login and password from the user and
check it with Test and test1234.
If the user sent the correct credentials output:
Successful login!
If the user sent the correct login name but the wrong password
output:
Login name is correct, incorrect password!
If the user sent an incorrect login name but the correct
password output:
Login name is incorrect, password accepted!
If the user sent both incorrect login name and password
output:
Unsuccessful login attempt!
The class method will return a boolean success variable as True
if the login was successful.
Using if __name__ == "__main__" to control the flow of
your code, add a loop that will stop the
process if the
user attempts more than 5 login attempts.
Ex: If the input is:
And this is their first incorrect attempt. The output is:
Unsuccessful login attempt!
Try again - you have 4 attempts left!
If the input is:
The output is:
LAB ACTIVITY 1.12.1: Lab: Check Login Credentials (classes) main.py def __init__(self): self.login_name 'none' self.login_password = 'none' 6 # TODO: Define class method - check_credentials(self, user_login, user_passwd) 8 9 if name__ "__main__": Login() 5 #variable used for login attempts input() = input() 1 class Login:| 2 HN3 +56 4 10 11 12 13 14 15 login = timeout login password 6/10 Load default template...
Complete the Login class
implementation. For the class method check_credentials(), you will
need to
accept two arguments - login and passwd. Do not forget about the
self argument.
This class method will set two local variables simlogin =
"Test" and simpass = "test1234".
These variables will simulate the correct login and password for
the credential check process.
The method will receive the login and password from the user and
check it with Test and test1234.
If the user sent the correct credentials output:
Successful login!
If the user sent the correct login name but the wrong password
output:
Login name is correct, incorrect password!
If the user sent an incorrect login name but the correct
password output:
Login name is incorrect, password accepted!
If the user sent both incorrect login name and password
output:
Unsuccessful login attempt!
The class method will return a boolean success variable as True
if the login was successful.
Using if __name__ == "__main__" to control the flow of
your code, add a loop that will stop the
process if the
user attempts more than 5 login attempts.
Ex: If the input is:
And this is their first incorrect attempt. The output is:
Unsuccessful login attempt!
Try again - you have 4 attempts left!
If the input is:
The output is:
LAB ACTIVITY 1.12.1: Lab: Check Login Credentials (classes) main.py def __init__(self): self.login_name 'none' self.login_password = 'none' 6 # TODO: Define class method - check_credentials(self, user_login, user_passwd) 8 9 if name__ "__main__": Login() 5 #variable used for login attempts input() = input() 1 class Login:| 2 HN3 +56 4 10 11 12 13 14 15 login = timeout login password 6/10 Load default template...