Founding Batch Offer ยท HLD ยท LLD ยท System Design at โ‚น799 until 30 Nov

Password Strength Checker

Score a practice password against five checks. Students combine len and any, add boolean results, and recognize why a classroom score is not a security guarantee.

AdvancedPhase 6 - Category 5: Real-World Logic ProblemsExample 1 of 15
password-strength-checker.py
1# Take password
2password = input("Enter password: ")
3
4# Check criteria
5has_length = len(password) >= 8
6has_upper = any(char.isupper() for char in password)
7has_lower = any(char.islower() for char in password)
8has_digit = any(char.isdigit() for char in password)
9has_special = any(not char.isalnum() for char in password)
10
11# Calculate strength
12score = sum([has_length, has_upper, has_lower, has_digit, has_special])
13
14if score == 5:
15 print("Strong password")
16elif score >= 3:
17 print("Medium password")
18else:
19 print("Weak password")

Output

Enter password: MyPass123!
Strong password

Enter password: password
Weak password

In this one

  • Combine boolean features
  • Score true checks as ones
  • Distinguish rules from security

How it works

  1. 1

    Calculate length, case, digit, and nonalphanumeric checks.

  2. 2

    Sum their boolean results.

  3. 3

    Choose Strong, Medium, or Weak from score thresholds.

Edge cases

Does a space satisfy the special check?

Does a space satisfy the special check?

Yes. A space is not alphanumeric.

Must Medium always have eight characters?

Must Medium always have eight characters?

No. Any three successful checks earn that label.

What's going on

The five checks cover length, uppercase, lowercase, a digit, and a nonalphanumeric character. Each boolean contributes one when summed because True behaves as one here.

A score of five prints Strong; scores three or four print Medium. Spaces satisfy the nonalphanumeric check, and a short password can still reach Medium through other checks. This is a rule score, not entropy measurement, safe storage, or a full security policy.

Does a space satisfy the special check? Yes. A space is not alphanumeric.

Must Medium always have eight characters? No. Any three successful checks earn that label.

Quiz

Tap an option. The answer stays hidden until you pick.

Question 1

What score gives Strong?

Pick an answer to check it.

Question 2

Does a space satisfy the special check?

Pick an answer to check it.

Questions people ask

Does a space satisfy the special check?

Yes. A space is not alphanumeric.

Must Medium always have eight characters?

No. Any three successful checks earn that label.

What score gives Strong?

5.