Raspberry Pi - GPIO Basics with PythonWhich 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)Check Answer
Step-by-Step SolutionSolution:Step 1: Import library correctlyThe standard import is 'import RPi.GPIO as GPIO'.Step 2: Set pin 23 as inputGPIO.setup(23, GPIO.IN) sets pin 23 as input.Final Answer:import RPi.GPIO as GPIO GPIO.setup(23, GPIO.IN) -> Option AQuick 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 pinWrong import statementMissing 'as GPIO' aliasConfusing input and output setup
Master "GPIO Basics with Python" in Raspberry Pi9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Raspberry Pi Quizzes GPIO Basics with Python - Setting pin mode (IN, OUT) - Quiz 12easy GPIO Basics with Python - GPIO pin numbering (BCM vs BOARD) - Quiz 9hard LED and Button Projects - Button press detection - Quiz 14medium PWM Output - RGB LED color mixing - Quiz 4medium Raspberry Pi Platform - Remote access with SSH - Quiz 10hard Raspberry Pi Platform - Python on Raspberry Pi - Quiz 8hard Raspberry Pi Platform - Raspberry Pi hardware overview (GPIO, USB, HDMI) - Quiz 2easy gpiozero Library - PWMLED for brightness - Quiz 8hard gpiozero Library - Buzzer and TonalBuzzer - Quiz 1easy gpiozero Library - Why gpiozero simplifies hardware - Quiz 7medium