Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part #2: Storing Passwords Write a Python program that creates passwords. Ask th

ID: 3834397 • Letter: P

Question

Part #2: Storing Passwords

Write a Python program that creates passwords. Ask the user to input their name. You will create two passwords for the user: one simple and one complex. The simple password will consist of first three letters of the last name followed by the first three letters of the first name and then a random number from zero through nine. The complex password will consist of five random punctuation symbols. You will create two dictionaries to store the passwords – one for the simple passwords and one for the complex passwords. Set up a loop to create three passwords for three users and then print out both dictionaries.

Explanation / Answer

users = {} status = "" while status != "q": status = raw_input("Are you a registered user? y/n? Press q to quit: ") if status == "n": #create new login createLogin = raw_input("Create login name: ") if createLogin in users: # check if login name exist in the dictionary print "Login name already exist! " else: createPassw = raw_input("Create password: ") users[createLogin] = createPassw # add login and password print(" User created! ") elif status == "y": #login the user login = raw_input("Enter login name: ") if login in users: passw = raw_input("Enter password: ") print if login in users and passw in users: # login matches password print "Login successful! " else: print print("User doesn't exist! ")