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.
1# Take password2password = input("Enter password: ")34# Check criteria5has_length = len(password) >= 86has_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)1011# Calculate strength12score = sum([has_length, has_upper, has_lower, has_digit, has_special])1314if 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
Calculate length, case, digit, and nonalphanumeric checks.
- 2
Sum their boolean results.
- 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.
๐Related Content
- ๐
Phase 6 - Learn Concepts
Review Phase 6 concepts and explanations
- ๐
Phase 6 - Quiz
Test your Phase 6 understanding with quiz questions
- ๐ป
Phase 6 - All Practice Problems
Explore all practice problems for Phase 6
- ๐
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- ๐ง
Logic Building Overview
Learn about the complete logic building curriculum