Question
Python 3.0 assignment: In apps that require logins, some, for security reasons, lock the use out after trying incorrectly to login for 3 or 5
Python 3.0 assignment:
In apps that require logins, some, for security reasons, lock the use out after trying incorrectly to login for 3 or 5 times. This is done by counting, where the counter is saved as a global variable. We won't be covering web or graphical apps, but the concept is the same.
Assume a user wants to login at a site and your code is the "back end" as it is called.
First show a menu of options (login, get help, about), then each time the user chooses to login, you will need to count, as shown below.
We will create a textual menu that shows 3 choices.
1. Login. 2. About. 3. Quit.
The user is expected to enter 1, and then you need to prompt them for their user ID and Password. In the code for main, pass the uid and password to a function called VerifyUser. If the functions returns False, then you need to first check if the counter is 3, then you need to display a Goodbye message. Else increment the global counter and display the number of incorrect attempts. If the user logs in correctly, display a welcome message. There's not much to do, as this is an incomplete app.
After the user chooses options 1 or 2, the code executes that menu option then shows the menu again. When the user chooses menu option 3, we do not repeat the menu.
This following is a partial code for main that you should add to, to make a complete application.
- def main(): print("Enter 1 to login") print("Enter 2 to see About page") print("Enter 3 to end")
choice = int(input("Make a choice: ")) if #choice is 1
#get user ID and Password and pass them to VerifyUser function #see prompt above for the rest # #call main
elif #choice is 2 #display some text about a company or a website #call main elif #choice is 3 #display a good bye message else #display a message that choice is invalid #call main
You need to write the VerifyUser function to return True if ID and Password are both correct. If the credentials are good, return True, else return False.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started