Bird
0
0

Which of the following is the correct way to create an LED object on GPIO pin 17 using the gpiozero library?

easy📝 Syntax Q12 of 15
Raspberry Pi - gpiozero Library

Which of the following is the correct way to create an LED object on GPIO pin 17 using the gpiozero library?

from gpiozero import LED

led = ?
ALED(17)
BLED.pin(17)
CLED[17]
DLED{17}
Step-by-Step Solution
Solution:
  1. Step 1: Recall LED object creation syntax

    In gpiozero, you create an LED by calling LED(pin_number), e.g., LED(17).
  2. Step 2: Check other options for syntax errors

    Options A, B, and D use invalid Python syntax for object creation.
  3. Final Answer:

    LED(17) -> Option A
  4. Quick Check:

    LED(pin) = LED(17) [OK]
Quick Trick: Use parentheses with pin number: LED(17) [OK]
Common Mistakes:
  • Using square brackets instead of parentheses
  • Trying to call a method like LED.pin()
  • Using curly braces which are invalid here

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes