computer4kids is now ComputerLeap. Same free lessons, same team. Read why we changed our name

← All lessons · 🧑‍💻 Coding Academy

🔐

🎓

⏱ 45 min

Free

Project: Password Strength Checker

Combine everything to build a real cybersecurity tool that rates passwords using NIST guidance.

🎯 What you will learn

  • Apply string methods to security
  • Score passwords with clear rules
  • Explain why long passphrases win

👋 Let’s get started!

Cybersecurity pros build tools like this 🔐. Your checker will score a password, explain its weaknesses and suggest improvements — based on NIST SP 800-63B, which says length beats complexity.

🪜 Step by step

1. 📏 Rules

Award points for length, variety and avoiding common passwords.

COMMON = {"password", "123456", "qwerty", "letmein"}
2. 🔎 Checks

any() with a generator checks each character type.

has_digit = any(ch.isdigit() for ch in pw)
has_upper = any(ch.isupper() for ch in pw)
3. 💬 Feedback

Collect tips in a list and print them.

tips = []
if len(pw) < 12:
    tips.append("Make it at least 12 characters")

🧪 Try it!

Change the code and press ▶ Run to see what happens. You can’t break anything!

Password Strength Checker

COMMON = {"password", "123456", "qwerty", "letmein", "iloveyou"}

def check(pw):
    score = 0
    tips = []
    if pw.lower() in COMMON:
        return 0, ["This is one of the most common passwords — pick something unique!"]
    if len(pw) >= 16:
        score += 3
    elif len(pw) >= 12:
        score += 2
    else:
        tips.append("Use 12+ characters — try a passphrase of 3-4 random words")
    if any(c.isdigit() for c in pw):
        score += 1
    else:
        tips.append("Add a number")
    if any(not c.isalnum() for c in pw):
        score += 1
    else:
        tips.append("Add a symbol like - or !")
    return score, tips

for pw in ["qwerty", "Sunshine1", "purple-tiger-eats-tacos-42"]:
    score, tips = check(pw)
    label = ["😱 Very weak", "😟 Weak", "😐 OK", "🙂 Good", "💪 Strong", "🦸 Super strong"][min(score, 5)]
    print(f"{pw!r}: {label}")
    for t in tips:
        print("   💡", t)

Length rule

def long_enough(pw):
    return len(pw) >= 12

print(long_enough("short"))

📖 Key words

Tap a card to flip it over!

Passphrase
A password made of several words 🐯🌮
Brute force
Guessing every possible password 🔨
NIST
US standards agency with password guidance 🏛️
Entropy
How unpredictable a password is 🎲

🏆 Challenge

Write has_symbol(pw) that returns True if the password contains any character that is not a letter or number. The code should print True then False.

Challenge

def has_symbol(pw):
    pass

print(has_symbol("hi-there"))
print(has_symbol("hithere"))

Knowledge Check Quiz

  1. According to NIST, what matters most?
  2. What prints?
  3. Why check against common passwords?
← Previous lesson