Bird
0
0

Identify the error in this Raspberry Pi Python authentication code:

medium📝 Debug Q6 of 15
Raspberry Pi - Security and Deployment
Identify the error in this Raspberry Pi Python authentication code:
username = 'pi'
password = 'raspberry'
input_user = input('Enter username: ')
input_pass = input('Enter password: ')
if input_user == username and input_pass = password:
    print('Access granted')
AMissing colon ':' after the if statement
BUsing '=' instead of '==' in the if condition
CIncorrect variable names for input_user and input_pass
DUsing 'and' instead of 'or' in the if condition
Step-by-Step Solution
Solution:
  1. Step 1: Check the if condition syntax

    The condition uses '=' which is assignment, not comparison.
  2. Step 2: Correct operator usage

    Replace '=' with '==' to compare input_pass with password.
  3. Final Answer:

    Using '=' instead of '==' in the if condition -> Option B
  4. Quick Check:

    Assignment operator used in condition [OK]
Quick Trick: Use '==' for comparisons in conditions [OK]
Common Mistakes:
MISTAKES
  • Using '=' instead of '==' in conditions
  • Forgetting colon ':' after if statement
  • Typos in variable names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes