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()