Count the Possible Passwords
Intermediate · Write the code · from Safe Computing: Privacy, Passwords, Encryption and Phishing
From the lesson: Safe Computing: Privacy, Passwords, Encryption and Phishing
Your phone, your browser and your apps collect a steady stream of data about you, and the same data that makes them convenient can be used to track you, trick you or steal from you.
Read the lessonWrite count_possible_passwords(password) that estimates how many passwords of the same length an attacker would have to try, based on the kinds of characters it uses:
Return the total number of possible characters raised to the power of the password's length.
count_possible_passwords("Ab1") -> 238328 (62 ** 3)def count_possible_passwords(password):
characters = 0
# Add 26, 26, 10 or 33 for each kind of character the password uses
return characters ** len(password)
What Check runs
Your code runs first, then each of these lines, and 2 more that stay hidden. The output must match exactly.
| Runs | Expected output |
|---|---|
| print(count_possible_passwords("abc")) | 17576 |
| print(count_possible_passwords("Ab1")) | 238328 |
| print(count_possible_passwords("tiger")) | 11881376 |
More Safe Computing exercises
- Caesar Cipher for Any TextIntermediate
- Spot PII Before You PostIntermediate