Question: Write a program that asks a user for his/her userid and password. The program tests the given userid and password against a file of userids

Write a program that asks a user for his/her userid and password. The program tests the given userid and password against a file of userids and passwords. The user gets three attempts to enter the information correctly. If the userid and password are correctly entered within three attempts, write a message to the screen informing the user that the userid and password were found. If not, write a message to the screen informing the user that the userid and password were not found. You can be as creative in your messages as you want, but no insulting comments. Users are sensitive creatures.

Whenever a user enters an incorrect userid or password, you have to allow him/her to reenter a userid and password, assuming it is within the three tries. This means that you have to begin the search at the beginning of the file.

You should have at least three functions:

1. An introduction intro that explains the process to the user;

2. A function getInfo that gets the userid and password from the user;

3. A function checkFile that positions the file unames_passwords.txt to the beginning of the file;

compares the userid and password entered by the user against the file of userids and

passwords. This function should return True, if the userid and password are found or return

False, if they are not found.

def main():

This function should call intro, open the file unames_passwords.txt as infile ; keep track of the number of tries; call the other two functions; and print out an appropriate reply (this could also be a function).

Remember to document your functions with appropriate comments after the function declaration

Proofread your comments and statements to the user. Your program should run correctly and the dialogue (output on the screen) should be pleasing to the eye.

Note: To position the file to the beginning, infile.seek(0) Question finish here.

This is notepad file which we have to use in this question.

msmith boxer

jblack spaniel

jdoe mutt

fblack lab

jprince mutt

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!