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

Testing password_strength() with password = f^BAcG Expected Return Value: 360 Ac

ID: 3741636 • Letter: T

Question

Testing password_strength() with password = f^BAcG
Expected Return Value: 360
Actual Return Value: 300
Incorrect!
Testing password_strength() with password = tlX
Expected Return Value: 75
Actual Return Value: 75
Correct!
Testing password_strength() with password = W63UtHTuN
Expected Return Value: 1170
Actual Return Value: 765
Incorrect!
Testing password_strength() with password = f
Expected Return Value: 5
Actual Return Value: 5
Correct!
Testing password_strength() with password = Msq08#2w&GpMm
Expected Return Value: 2275
Actual Return Value: 1300
Incorrect!
Testing password_strength() with password = qHjTt9YQ
Expected Return Value: 680
Actual Return Value: 520
Incorrect!
Testing password_strength() with password = gw74X5I2
Expected Return Value: 1240
Actual Return Value: 760
Incorrect!
Testing password_strength() with password = &9@%B9T(jZJ
Expected Return Value: 1870
Actual Return Value: 1045
Incorrect!
Testing password_strength() with password = y*n(q%XxVp2
Expected Return Value: 1540
Actual Return Value: 1100
Incorrect!
Testing password_strength() with password = !fxus
Expected Return Value: 225
Actual Return Value: 225
Correct!
Testing password_strength() with password = @l1V*l
Expected Return Value: 510
Actual Return Value: 510
Correct!
Testing password_strength() with password = pJSmXIqrmUD
Expected Return Value: 990
Actual Return Value: 550
Incorrect!
Testing password_strength() with password = Annulx%
Expected Return Value: 595
Actual Return Value: 595
Correct!
Testing password_strength() with password = !$p$egYSW
Expected Return Value: 945
Actual Return Value: 720
Incorrect!
Testing password_strength() with password = (Q*Zjbg6aDh2
Expected Return Value: 2040
Actual Return Value: 1800
Incorrect!
Testing password_strength() with password = x*rX4HP#xI
Expected Return Value: 1150
Actual Return Value: 800
Incorrect!
Testing password_strength() with password = %gU
Expected Return Value: 135
Actual Return Value: 135
Correct!
Testing password_strength() with password = gFVI
Expected Return Value: 160
Actual Return Value: 120
Incorrect!
Testing password_strength() with password = 1dawHi488zrQ
Expected Return Value: 2040
Actual Return Value: 1440
Incorrect!
Testing password_strength() with password = R
Expected Return Value: 40
Actual Return Value: 40
Correct!
########################################

Part I: Password Strength Calculator (20 points) Write a function password strength ) that takes one argument, password, which is a string of characters consisting of lowercase letters, uppercase letters, digits and non-alphanumerical symbols. The function allocates points to password based on the location of certain characters in the string:

Explanation / Answer

import re def password_strength(password): points = 0 # it will give string except first or last character remainingPass = password[1:-1] # if first is digit if (password[0].isdigit()): points += 40 elif (password[0].isupper()): points += 25 elif (not password[0].isdigit() and not password[0].isupper() and not password[0].islower()): points += 25 else: points += 5 print(points) # is last is digit if (password[len(password) - 1].isdigit()): points += 50 elif (password[len(password) - 1].isupper()): points += 15 elif (not password[len(password) - 1].isdigit() and not password[len(password) - 1].isupper() and not password[len(password) - 1].islower()): points += 35 else: points += 5 print(points) # if digit is somewhere else #if (any(char.isdigit() for char in remainingPass)): #points += 25 #if (any(char.isupper() for char in remainingPass)): #points += 10 # for all lower case letter add 5 points for c in remainingPass: if c.islower(): points += 5 elif c.isupper(): points += 10 elif c.isdigit(): points += 25 else: points += 15 print(points) #letterWithSymbol = re.sub('[w]+', '', remainingPass) #if (len(letterWithSymbol) != 0): #points += 15 return points * len(password) if __name__ == '__main__': print(password_strength("f^BAcG")) print(password_strength("tlX")) print(password_strength("!fxus")) print(password_strength("&9@%B9T(jZJ"))

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