Knowee
Questions
Features
Study Tools

A student is writing a program that requires a user to create a password when they register a new account. To verify the password, the program requires the user to confirm the password they created by entering it a second time. The code for the routine is shown below.01 password = input('Please enter password:')02 storedPassword = password03 password = input('Confirm password:')04 if password != storedPassword then05 print('Passwords do not match')06 else07 print('Password accepted')08 endifState why the program only allows one attempt to match the passwords and outline how the program could be changed to enable the user to have up to three attempts to match the two passwords. You are not required to rewrite the code.[4]

Question

A student is writing a program that requires a user to create a password when they register a new account. To verify the password, the program requires the user to confirm the password they created by entering it a second time. The code for the routine is shown below.01 password = input('Please enter password:')02 storedPassword = password03 password = input('Confirm password:')04 if password != storedPassword then05 print('Passwords do not match')06 else07 print('Password accepted')08 endifState why the program only allows one attempt to match the passwords and outline how the program could be changed to enable the user to have up to three attempts to match the two passwords. You are not required to rewrite the code.[4]

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The program only allows one attempt to match the passwords because the password confirmation process is not inside a loop. Once the user enters the password for the second time, the program checks if it matches the first password. If it doesn't, it prints 'Passwords do not match' and ends. There is no mechanism to allow the user to try again.

To enable the user to have up to three attempts to match the passwords, the password confirmation process should be placed inside a loop that iterates up to three times. The loop should break if the passwords match. If the passwords do not match after three attempts, the program should print 'Passwords do not match' and end. If the passwords match within the three attempts, the program should print 'Password accepted' and end.

This problem has been solved

Similar Questions

Python program to check the validity of username and password input by users

Suggest how verification can be used when entering the password.

Develop a Python script to simulate a basic user authentication system using if-else statementsand logical operators. The script should prompt the user for a username and password and validatethem against predefined credentials

Check if a string is matching password requirements Sample inputProgram#123Sample outputSuccessfully Matched with the Password Requirements.ExplanationRead a string which should satisfy the password requirements.If the string satisfies the given requirements print "Successfully Matched with the Password Requirements." without double quotes.if not satisfied print "Not Matched with the Password Requirements." without the double quotes.Password Requirements :Atleast one Uppercase character.Atleast one Lowercase character.Atleast one special Character.Atleast one Number.The string should be more than 8 characters long. SAMPLE INPUT:  Program#12SAMPLE OUTPUT:Successfully Matched with the Password Requirements.Note:Your code must be able to print the sample output from the provided sample input. However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement.

In this following code, what is __password?class User: id = 89 name = "no name" __password = None def __init__(self, new_name=None): self.is_new = True if new_name is not None: self.name = new_name

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.