Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I wanna know what wrong with this code: import re def password_strength(password): points = 0; # it will give string except first or last character

image text in transcribedimage text in transcribedI wanna know what wrong with this code:

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; # is last is digit  if (password[len(password) - 1].isdigit()): points += 50; # if digit is somewhere else  if (any(char.isdigit() for char in remainingPass)): points += 25; if (password[0].isupper()): points += 25; if (password[len(password) - 1].isupper()): points += 15; if (any(char.isupper() for char in remainingPass)): points += 10; # for all lower case letter add 5 points  for c in password: if (c.islower()): points += 5; if (not password[0].isdigit() and not password[0].isupper() and not password[0].islower()): points += 25; if (not password[len(password) - 1].isdigit() and not password[len(password) - 1].isupper() and not password[ len(password) - 1].islower()): points += 35; letterWithSymbol = re.sub('[\w]+', '', remainingPass); if (len(letterWithSymbol) != 0): points += 15; return points * len(password);

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

understand the key issues concerning international assignments

Answered: 1 week ago