Bird
0
0

What will be the output of this Python code running on a Raspberry Pi that checks if a device is secure based on password strength?

medium📝 Predict Output Q13 of 15
Raspberry Pi - Security and Deployment
What will be the output of this Python code running on a Raspberry Pi that checks if a device is secure based on password strength?
password = 'abc123'
if len(password) >= 8 and any(c.isdigit() for c in password) and any(c.isalpha() for c in password):
    print('Secure')
else:
    print('Not Secure')
ASecure
BNot Secure
CSyntaxError
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Check password length condition

    The password 'abc123' has length 6, which is less than 8, so the first condition fails.
  2. Step 2: Evaluate the full if condition

    Since the length condition is false, the whole condition is false, so the else block runs.
  3. Final Answer:

    Not Secure -> Option B
  4. Quick Check:

    Password length < 8 = Not Secure [OK]
Quick Trick: Check length first; less than 8 means not secure [OK]
Common Mistakes:
MISTAKES
  • Ignoring length check
  • Assuming presence of digits and letters is enough
  • Confusing syntax with logic errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes