Consider this Python code snippet for Raspberry Pi GPIO setup. What will it print?
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.OUT) GPIO.output(18, GPIO.HIGH) print(GPIO.input(18))
GPIO.HIGH corresponds to logical 1 when reading the pin output.
Setting pin 18 to output and writing GPIO.HIGH means reading it returns 1.
Which reason best explains why learning GPIO programming is foundational for Raspberry Pi?
Think about what GPIO pins connect to in real life.
GPIO pins let you connect and control real-world devices, making programming interactive and physical.
What error will this code produce when run on a Raspberry Pi?
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIO.IN) value = GPIO.input(23) print(value) GPIO.cleanup()
Check if the pin is properly set as input before reading.
The code correctly sets pin 23 as input and reads its value, so it runs without error.
Choose the code snippet that correctly sets GPIO pin 17 as output and sets it to LOW.
Remember to set the pin mode before writing output.
Pin must be set as output before writing LOW. Option A does this in correct order.
Given the Raspberry Pi 4 hardware, how many GPIO pins can you use at the same time as outputs?
Check Raspberry Pi 4 GPIO pin capabilities.
All GPIO pins on Raspberry Pi 4 can be configured as input or output independently.