Bird
0
0

What will be the output of this Python code on Raspberry Pi?

medium📝 Predict Output Q13 of 15
Raspberry Pi - Security and Deployment
What will be the output of this Python code on Raspberry Pi?
username = 'pi'
password = 'raspberry'
input_user = 'pi'
input_pass = 'wrongpass'

if input_user == username and input_pass == password:
    print('Access granted')
else:
    print('Access denied')
AAccess granted
BSyntaxError
CNo output
DAccess denied
Step-by-Step Solution
Solution:
  1. Step 1: Compare input username and password

    input_user matches username 'pi', but input_pass is 'wrongpass', not 'raspberry'.
  2. Step 2: Evaluate the if condition

    Since password check fails, condition is false, so else block runs.
  3. Final Answer:

    Access denied -> Option D
  4. Quick Check:

    Password mismatch means access denied [OK]
Quick Trick: Both username and password must match exactly [OK]
Common Mistakes:
MISTAKES
  • Assuming partial match grants access
  • Confusing syntax error with logic error
  • Ignoring else block output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes