Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Python program to determine whether a password meets all the requirements for a secure password

Python program to determine whether a password meets all the requirements for a secure password

Computer Science

Python program to determine whether a password meets all the requirements for a secure password. Your program should prompt the user for the candidate password and output either that the password is valid or the reason it is invalid. To be valid the length of the password must greater than some minimum length but less than some maximum. It must not include the substring "umgc" in any combination of upper or lower case letters. Finally, it must contain the # symbol is some position other than the first or last character. You should decide on the minimum and maximum allowable lengths.

Your program should include the pseudocode used for your design in the comments. Document the values you chose for the minimum and maximum allowable lengths in your comments as well.

 

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

Answer:

#Take input from user

password = input("Enter the password: ")

 

#Find the length of the password

length_password = len(password)

 

#Initialize the max and min length of password

max_length = 10

min_length = 8

 

#Check if the length of password is within the min and max values 

if len(password) >= min_length and len(password) <= max_length:

 

  #Check if the sub-string "umgc" is present in the password

  if password.lower().find("umgc") == -1:

 

    #Check if the password have "#" in it and not at position first and last

    if "#" in password and password[0] != '#' and password[-1]!='#':

      #If all conditions true print the success statement.

      print("You have entered a valid password!")

    else:

      #Error if # is not used or used at illegal places

      print("Invalid password!")

  else:

    #Error if the password has the string "umgc"

    print("Invalid password!")

else:

  #Error if the length of string is not within specified ranges.

  print("Invalid password!")