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

Write a Python program that uses regular expressions to check user-defined passw

ID: 3528947 • Letter: W

Question

Write a Python program that uses regular expressions to check user-defined passwords. The password must 1. be at least 8 characters and not more than 40 characters long, 2. not contain anything other than alphanumeric characters, 3. contain at least one letter (a-z or A-Z) and one digit (0-9) in the interior of the string, 4. contain at least one uppercase and one lowercase character, 5. not contain any English word of 4 letters or more, 6. not contain any string of three or more of the same character in a row (e.g., aaa or 8888) 7. not contain more than one copy of any string of 4 or more characters, 8. not contain any two-digit number that is immediately preceded by the string bd (e.g., bd93), and 9. not contain any 8-digit string that represents a date in the last 100 years (e.g., 02042013 represents February 4th, 2013).

Explanation / Answer

# program to rot13 encode a given password, here 'nixon' # copy the result into your program that needs this password # and then use encode('rot13') to match user password password = 'nixon' encoded_password = password.encode('rot13') print(encoded_password) # avkba Then use the encoded password in your main program, This way you don't give away the password in your code: # program to use a rot13 encoded password, here 'avkba' print('I will tell you a story if you enter the correct password') # loop until the correct password has been entered while True: # for Python3 remove 'raw_' pw = raw_input("Enter the password: ") if pw.encode('rot13') == 'avkba': print("Well, here is my story ...") break else: print("password did not match, try again!")

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