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

Write a Python program that creates passwords. Ask the user to input their name.

ID: 3835433 • Letter: W

Question

Write a Python program that creates passwords. Ask the user to input their name. You will create two passwords for the user: one simply and one complex. The simple password will consist of the 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 puncuation symbols.

You must 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.

If possible, keep the code as simple as you can. We've only learned the basics of libraries, loops, etc. Anything too in depth would not work. Thank you!

Explanation / Answer

from random import randint, shuffle
import string

def create_simple_password(user):
(first, last) = user.split()
return last[0:3] + first[0:3] + str(randint(0, 9))

def create_complex_password():
punc = list(string.punctuation)
shuffle(punc)
return "".join(punc[0:5])
  
simple_passwords = {}
complex_passwords = {}
for i in range(0, 3):
user = input("Enter your name<first last>: ")
user = user.strip()
simple_passwords[user] = create_simple_password(user)
complex_passwords[user] = create_complex_password()

print(simple_passwords)
print(complex_passwords)

# code link: https://paste.ee/p/XCqS6

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote