Question

Lab 3: Databased Admin Tool Python Objective: Develop an admin tool for username and password management. You will need...

Lab 3: Databased Admin Tool Python

Objective: Develop an admin tool for username and password management. You will need to use the best data structure to store the data you read from UD.txt for efficient processing. You can accomplish these tasks with Dictionary or List.

The data file (UD.txt) :

FIRST NAME, LAST NAME,USERNAME,PASSWORD

Sam, DDal,sdd233,Pad231

Dave,Dcon,dcf987, BHYW4fw

Dell,Grant,dgr803,Sb83d2d

Mike,Kress,mkr212,UNNHS322

Lisa,Kate,lki065,dgw6234

Paul,Edward,ped332,9891ds

Youyou,Tranten,ytr876,dsid21kk

Nomi,Mhanken,nmh223,3282jd3d2

Write a program that imports the database from UD.txt

Give the following options:

A: Search by last name

B: Search by first name

C: Search by username

D: Display all users alphabetically by First name

E. Display all users alphabetically by Last name

F: Insert a user

  1. When user select A, prompt the user “Enter user’s last name:”

If the user is found, display the user’s info. For example: Sam, DDal,sdd233,Pad231

If user not found, display “Not found”, and return the user to main menu

  1. When user select B, prompt the user “Enter user’s first name:”

If the user is found, display the user’s info. For example: Sam, DDal,sdd233,Pad231

If user not found, display “Not found”, and return the user to main menu

  1. When user select C, prompt the user “Enter user’s username:”

If the user is found, display the user’s info. For example: Sam, DDal,sdd233,Pad231

If user not found, display “Not found”, and return the user to main menu

  1. For D, display all the user’s information with First name in alphabetically order. For example, with our current database, “Dave, Dcon,dcf987, BHYW4fw” will appear first, and “Youyou,Tranten,ytr876,dsid21kk” will appear last.
  2. For E, display all the user’s information with Last name in alphabetically order. For example, with our current database, “Dave, Dcon,dcf987, BHYW4fw” will appear first, and “Youyou,Tranten,ytr876,dsid21kk” will appear last.
  3. For F, prompt the user “Enter user info in the following format: First name, last name, username, password”, process the string and save the information into the UD.txt.

Important: Declare one function called “def output ()” to output information for option D and E.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

source code:

#Please go through comments and modify if any thing required thank you

#screenshots provided for indentation and reference purposes


#output function for D and E options
#prints the list if provided
def output(data):
print('{0: <20}{1: <20}{2: <20}{3: <20}'.format("FIRST NAME","LAST NAME","USERNAME","PASSWORD"))
for ml in data:
print('{0: <20}{1: <20}{2: <20}{3: <20}'.format(ml[0],ml[1],ml[2],ml[3]))
  
#main function
def main():
file=open("UD.txt","r") #text file opening
ml=list()
i=0
for line in file: #reading line by line and listing all contents as each list
if i!=0:
ll=line.split(",")
ml.append(ll)
i=1
file.close() #closed text file
print("Select from following options:\n") #user given with options
print("A: Search by last name\nB: Search by first name\nC: Search by username\nD: Display all users alphabetically by First name\nE. Display all users alphabetically by Last name\nF: Insert a user\n")
ch=input("Q for quit.")
while(True):
if ch=='Q':#quits
break;
elif ch=='A':#searches content using last name
name=input("Enter last name to Search: ")
i=0
j=0
for ll in ml:
if ll[1]==name:
i=j
break;
j=j+1
if i==0:
print("Not Found")
else:
print('{0: <20}{1: <20}{2: <20}{3: <20}'.format(ml[i][0],ml[i][1],ml[i][2],ml[i][3]))
elif ch=='B':#searches name using first name
name=input("Enter first name to Search: ")
i=0
j=0
for ll in ml:
if ll[0]==name:
i=j
break;
j=j+1
if i==0:
print("Not Found")
else:
print('{0: <20}{1: <20}{2: <20}{3: <20}'.format(ml[i][0],ml[i][1],ml[i][2],ml[i][3]))
elif ch=='C':#searches using usrname
name=input("Enter username to Search: ")
i=0
j=0
for ll in ml:
if ll[2]==name:
i=j
break;
j=j+1
if i==0:
print("Not Found")
else:
print('{0: <20}{1: <20}{2: <20}{3: <20}'.format(ml[i][0],ml[i][1],ml[i][2],ml[i][3]))
elif ch=='D':#sorts the data using first name
rl=ml
rl.sort(key=lambda x:x[0])
output(rl)
elif ch=='E':#sorts data using last name
rl=ml
rl.sort(key=lambda x:x[1])
output(rl)
elif ch=='F':#writest to text file
det=input("Enter user info in the following format: First name, last name, username, password:")
file=open("UD.txt","a")
file.write("\n")
file.write(det)
file.close
print("Select from following options:\n")
print("A: Search by last name\nB: Search by first name\nC: Search by username\nD: Display all users alphabetically by First name\nE. Display all users alphabetically by Last name\nF: Insert a user\n")
ch=input("Q for quit.")


if __name__ == '__main__':
main()

#output function for D and E options #prints the list if provided def output (data): print( (0: <20) I1: <20 12: <20) [3: <2

34 35 break; 36 37 j-j+1 if İ--0: 38 print (Not Found) 39 else: 40 <20)(1: elif ch--3:#searches name using first name nam

56 i-0 57 58 for 11 in ml: 59 if 11 121--name: 60 61 break; i-j+1 62 63 64 print (Not Found) 65 clsc: print 10: <20)1: <20

Sellect from folLowing optilons: A: Search by last name B Search by first name C: Search by username D: Display all users alp

Q for quit.c Enter username to Search: ped332 Paul 9891ds ped332 Select from following options: A: Search by last name B Sear

Select from following options: A: Search by last name B: Search by first name C: Search by username D: Display all users alph

Select from following options: A: Search by last name B: Search by first name C: Search by username D: Display all users alph

Add a comment
Know the answer?
Add Answer to:
Lab 3: Databased Admin Tool Python Objective: Develop an admin tool for username and password management. You will need...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Lab 4: Databased Admin Tool Continued Python Objective: In the previous lab, you developed an admin tool for username an...

    Lab 4: Databased Admin Tool Continued Python Objective: In the previous lab, you developed an admin tool for username and password management. You accomplished the tasks with Dictionary or List. Here, use class to design your own data structure to accomplish a similar task. The UD.txt datafile: FIRST NAME, LAST NAME,USERNAME,PASSWORD Sam, DDal,sdd233,Pad231 Dave, Dcon,dcf987, BHYW4fw Dell, Grant,dgr803,Sb83d2d Mike, Kress,mkr212,UNNHS322 Lisa,Kate,lki065,dgw6234 Paul,Edward,ped332,9891ds Youyou,Tranten,ytr876,dsid21kk Nomi,Mhanken,nmh223,3282jd3d2 Write a program that imports the database from UD.txt, your program can search for users’ password....

  • In C , checks if the entered password for admin is correct by calling checkAdminPassword. Part...

    In C , checks if the entered password for admin is correct by calling checkAdminPassword. Part of this function has been implemented, complete the statement in if(). Keep in mind that the entered password is plaintext whereas the password in struct user is in the hashsed form. The password for user admin is “s#1Pa5”. int checkAdminPassword(char* password, struct user* users, int count) { for (int i = 0; i < count; ++i) { if (strcmp((users + i)->username, "admin") == 0)...

  • Lab Assignment – Database Implementation and Security In this lab you will create a Microsoft Access database of employee information and secure the table username and password security. Steps Enter...

    Lab Assignment – Database Implementation and Security In this lab you will create a Microsoft Access database of employee information and secure the table username and password security. Steps Enter data for five employee records. Each record should have fields: Employee ID (5 digits), First Name, Last Name, Home Address, Hire Date Create a query that displays Employee ID, First Name and Last Name. Create a form that requires entering username and password to access employee table. Error message should...

  • Using Python INST-FS-IAD-PROD.INS LAB1 Lab: Create User Account 2. get-password() #promt the user and create password, check the password fits the requirement USE the EXACT file names! Create a user...

    Using Python INST-FS-IAD-PROD.INS LAB1 Lab: Create User Account 2. get-password() #promt the user and create password, check the password fits the requirement USE the EXACT file names! Create a user login system. Your code should do the following: 3, create-user_name() #use this function to create the user name 1.Create your user database called "UD.txt", this should be in CSV format 4, write-file() #user this function to save the user name and password into "UD.txt" Deliverables: Sample: the data you saved...

  • Lab Assignment – Database Implementation and Security In this lab you will create a Microsoft Access...

    Lab Assignment – Database Implementation and Security In this lab you will create a Microsoft Access database of employee information and secure the table username and password security. Steps Enter data for five employee records. Each record should have fields: Employee ID (5 digits), First Name, Last Name, Home Address, Hire Date Create a query that displays Employee ID, First Name and Last Name. Create a form that requires entering username and password to access employee table. Error message should...

  • Java Inventory Management Code Question

    Inventory ManagementObjectives:Use inheritance to create base and child classesUtilize multiple classes in the same programPerform standard input validationImplement a solution that uses polymorphismProblem:A small electronics company has hired you to write an application to manage their inventory. The company requested a role-based access control (RBAC) to increase the security around using the new application. The company also requested that the application menu must be flexible enough to allow adding new menu items to the menu with minimal changes. This includes...

  • InventoryManagement

    Problem:A small electronics company has hired you to write an application to manage their inventory. The company requested a role-based access control (RBAC) to increase the security around using the new application. The company also requested that the application menu must be flexible enough to allow adding new menu items to the menu with minimal changes. This includes re-ordering the menu items and making changes to the description of a menu item without having to change the code.Security:The company has...

  • Using MySQL and PHP keep it simple This assignment you will be making a form that...

    Using MySQL and PHP keep it simple This assignment you will be making a form that will do one of three things in a database -          It will add a record -          It will update a record -          It will search for a record Your database will contain a table for keeping a record of all your friends and family and should contain: First name Last name Phone number Address City State Zip Birthdate Username Password The sex of the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT