Your program should include the following four functions:
check_length - This function should accept a password to evaluate as a parameter and should return a score based on the length of the password. A password that is less than 8 characters long gets a length score of 1. If it is between 8 and 11 characters long (inclusive), it gets a length score of 2. A password that is 12 characters or longer gets a length score of 3.
check_case - This function should accept a password to evaluate and return a case score of 1 or 2. If the letters in the password are all uppercase or all lowercase, the case score should be a 1. If there is a mix of uppercase or lowercase letters (or if there are no letters at all), it gets a case score of 2.
check_content - This function should accept a password to evaluate and return a content score. If the characters are all alphabetic characters, the content score is 1. If the characters include any numeric digits (either all numeric or a mix of letters and digits), the content score is 2. If there are any other types of characters (such as punctuation symbols), the content score is 3.
main - This function represents the main program. It accepts no parameters and returns no value. It contains the loop that allows the user to process as many passwords as desired. It function calls the other functions as needed, computing the overall score by adding up the scores produced by each function. All output should be printed in the main function.
python please

Respuesta :

Answer:

def main():

   pwd = input("Password: ")

   print("Length: "+str(check_length(pwd)))

   print("Case: "+str(check_case(pwd)))

   print("Content: "+str(check_content(pwd)))

   

def check_length(pwd):

   lent = len(pwd)

   if lent < 8:

       return 1

   elif lent >=8 and lent <= 11:

       return 2

   else:

       return 3

   

def check_case(pwd):

   if(pwd.isupper() or pwd.islower()):

       return 1

   else:

       return 2

   

def check_content(pwd):

   if(pwd.isalpha()):

       return 1

   elif(pwd.isalnum()):

       return 2

   else:

       return 3

   

if __name__ == "__main__":

   main()

Explanation:

The main begins here

def main():

This prompts the user for password

   pwd = input("Password: ")

This calls the check_length function

   print("Length: "+str(check_length(pwd)))

This calls the check_case function

   print("Case: "+str(check_case(pwd)))

This calls the check_content function

   print("Content: "+str(check_content(pwd)))

The check_length function begins here    

def check_length(pwd):

This calculates the length of the password

   lent = len(pwd)

If length is less than 8, it returns 1

   if lent < 8:

       return 1

If length is less than between 8 and 11 (inclusive), it returns 2

   elif lent >=8 and lent <= 11:

       return 2

If otherwise, it returns 3

   else:

       return 3

The check_case function begins here    

def check_case(pwd):

If password contains only uppercase or only lowercase, it returns 1

   if(pwd.isupper() or pwd.islower()):

       return 1

If otherwise, it returns 2

  else:

       return 2

The check_content function begins here

def check_content(pwd):

If password is only alphabet, it returns 1

   if(pwd.isalpha()):

       return 1

If password is only alphanumeric, it returns 2

   elif(pwd.isalnum()):

       return 2

If otherwise, it returns 3

   else:

       return 3

This calls the main function    

if __name__ == "__main__":

   main()