Bird
0
0

Which of the following is the correct syntax to import the GPIO library and set pin 23 as input?

easy📝 Syntax Q3 of 15
Raspberry Pi - GPIO Basics with Python
Which of the following is the correct syntax to import the GPIO library and set pin 23 as input?
Aimport RPi.GPIO as GPIO GPIO.setup(23, GPIO.IN)
Bimport GPIO GPIO.setup(23, GPIO.OUT)
Cimport RPi.GPIO GPIO.setup(23, GPIO.OUT)
Dimport RPi.GPIO as GPIO GPIO.setup(23, GPIO.OUT)
Step-by-Step Solution
Solution:
  1. Step 1: Import library correctly

    The standard import is 'import RPi.GPIO as GPIO'.
  2. Step 2: Set pin 23 as input

    GPIO.setup(23, GPIO.IN) sets pin 23 as input.
  3. Final Answer:

    import RPi.GPIO as GPIO GPIO.setup(23, GPIO.IN) -> Option A
  4. Quick Check:

    Import and setup input pin correctly [OK]
Quick Trick: Use 'import RPi.GPIO as GPIO' and GPIO.IN for input [OK]
Common Mistakes:
  • Using GPIO.OUT for input pin
  • Wrong import statement
  • Missing 'as GPIO' alias
  • Confusing input and output setup

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes