##Example 1 password = input("What is your potential password? ") lower = "abcdefghijklmnopqrstuvwxyz" upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" number = "0123456789" score = 0 lscore = 0 uscore = 0 nscore = 0 sscore = 0 for num in range(len(password)): score = score + 1 for character in password: if character in lower: lscore = 1 elif character in upper: uscore = 1 elif character in number: nscore = 1 else: sscore = 1 total_score = score + lscore + uscore + nscore + sscore print("Final score is "+str(total_score)) if total_score <=10: strength = "weak" elif total_score == 11 or total_score == 12: strength = "okay" elif total_score >= 13 and total_score <=15: strength = "good" else: strength = "strong" print("That is " + str(strength)) ######################### ##Example 2 password = input("What is your password? ") score = len(password) lower = "abcdefghijklmnopqrstuvwxyz" upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" digits = "0123456789" lowercategory = 0 uppercategory = 0 digitcategory = 0 specialcategory = 0 for index in range (len(password)): character = password[index] if character in lower and lowercategory == 0: score = score + 1 lowercategory = 1 if character in upper and uppercategory == 0: score = score + 1 uppercategory = 1 if character in digits and digitcategory == 0: score = score + 1 digitcategory = 1 if character not in lower and character not in upper and character not in digits and specialcategory == 0: score = score + 1 specialcategory = 1 if score <= 10: strength = "weak" elif score >10 and score <=12: strength = "okay" elif score >12 and score <= 15: strength = "good" elif score >15: strength = "strong" print ("Final score is "+str(score)) print ("That score is "+strength) ######################### ##Example 3 pswd= input("What is your password? ") upper= ("A", "B","C","D","E","F","G","H","I","J","K","L","M", "N","O","P","Q","R","S","T","U","V","W","X","Y","Z") lower = ("a","b","c","d","e","f","g","h","i","j","k","l","m", "n","o","p","q","r","s","t","u","v","w","x","y","z") digits = ("1","2","3","4","5","6","7","8","9","0") special= ("!","@","#","$","%","^","&","*","(",")") score = 0 up = 0 low = 0 digitct= 0 specials = 0 for char in pswd: score = score + 1 if char in upper: up = up + 1 elif char in lower: low = low + 1 elif char in digits: digitct = digitct + 1 elif char in special: specials = specials + 1 if low > 0: score = score + 1 if up > 0: score = score + 1 if digitct > 0: score = score + 1 if specials > 0: score = score + 1 print("Final score is",score) if score <= 10: print("That is weak") elif score <= 12: print("That is okay") elif score <= 15: print("That is good") elif score > 15: print("That is strong") ######################### ##Example 4 digits="0123456789" length=0 counter=0 lower=0 upper=0 number=0 special=0 x=input("What is your potential password? ") for i in range(len(x)): character=x[i] length=i+1 if character.islower(): lower=1 counter=counter+1 if character.isupper(): upper=1 counter=counter+1 if character in digits: number=1 counter=counter+1 if counter=11 and score <=12: print("That is okay") elif score>=13 and score<=15: print("That is good") else: print("That is strong")