All changes saved to local database
ML - discrete structures
Instructions

As applications become more secure, password requirements have grown beyond simple length checks. Modern systems often require a combination of uppercase letters, lowercase letters, numbers, and special characters to protect user accounts from unauthorized access. In this challenge, you will build a validation engine that determines whether a password string satisfies a strict set of security protocols.

Methodology

To evaluate the strength of a password (PP), we must verify five independent logical constraints. A password is only considered secure if the intersection of all these conditions is true:

Step 1: Length Validation The total number of characters in the string must be eight or greater.

len(P)8len(P) \ge 8

Step 2: Character Classification We must iterate through the string and identify the presence of at least one character from each of the following sets:

cU,cL,cD,cSc \in U, \quad c \in L, \quad c \in D, \quad c \in S
  • Uppercase (UU): {A,B,C,,Z}\{A, B, C, \ldots, Z\}
  • Lowercase (LL): {a,b,c,,z}\{a, b, c, \ldots, z\}
  • Digits (DD): {0,1,2,9}\{0, 1, 2 \ldots, 9\}
  • Special Characters (SS): {!,@,#,$,%,,&,}\{!, @, \#, \$, \%, \wedge, \&, *\}

Implementation

The most efficient implementation involves a single pass (iteration) through the string. During this loop, you can use Python’s built-in string methods to classify each character. For special characters, a membership check against the allowed set is required.

🛠️ System Note: You can utilize methods like .isupper().islower(), and .isdigit() to evaluate individual characters. For the special character requirement, define a reference string containing !@#$%^&*.

Consider the password "P@ssw0rd":

  1. Length: 888 \geq 8 (Pass)
  2. Uppercase: Contains 'P' (Pass)
  3. Lowercase: Contains 's', 'w', 'r', 'd' (Pass)
  4. Digit: Contains '0' (Pass)
  5. Special: Contains '@' (Pass)
  6. Result: True

Validation

To ensure your solution passes our automated verification system (==), you must satisfy the following:

  1. Return Type: The function must return a Boolean value (True or False).
  2. Strict Symbols: Only the specific characters !@#$%^&* count toward the "Special Character" requirement.

The Challenge

Implement the function check_password_strength(password). It must accept a string and return True if it satisfies all security rules, or False otherwise.

def check_password_strength(password): # Step 1: Check length # Step 2: Initialize trackers for character types # Step 3: Iterate through the string and classify characters # Final Step: Return True only if all criteria are met pass

solution.py
Terminal