Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q4 of 15
Raspberry Pi - gpiozero Library
What will be the output of this code?
from gpiozero import LED
led = LED(17)
led.off()
print(led.is_lit)
AError
BTrue
CNone
DFalse
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the code

    The LED is created on GPIO 17 and then turned off with led.off().
  2. Step 2: Understand is_lit

    The is_lit property returns True if the LED is on, otherwise False.
  3. Final Answer:

    False -> Option D
  4. Quick Check:

    LED off means is_lit is False [OK]
Quick Trick: LED off means is_lit returns False [OK]
Common Mistakes:
  • Assuming is_lit returns True by default
  • Confusing led.off() with led.on()
  • Expecting None or error output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes