Bird
0
0

What will be the output on the Raspberry Pi display after running this Python code?

medium📝 Predict Output Q13 of 15
Raspberry Pi - Display and Output
What will be the output on the Raspberry Pi display after running this Python code?
status = 'ON'
if status == 'ON':
    print('Device is active')
else:
    print('Device is inactive')
ASyntaxError
BDevice is inactive
CNo output
DDevice is active
Step-by-Step Solution
Solution:
  1. Step 1: Check the value of the variable 'status'

    The variable status is set to 'ON'.
  2. Step 2: Evaluate the if condition

    The condition status == 'ON' is true, so the first print runs.
  3. Final Answer:

    Device is active -> Option D
  4. Quick Check:

    status 'ON' triggers 'Device is active' [OK]
Quick Trick: Check variable value before if condition [OK]
Common Mistakes:
MISTAKES
  • Ignoring the if condition
  • Assuming else runs first
  • Thinking code has syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes