What is the output of this Python code snippet that reads a GPIO pin state on a Raspberry Pi?
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP) state = GPIO.input(18) print(state)
Consider the pull-up resistor setting and what it means for the input pin state when nothing is connected.
The pin 18 is set as input with a pull-up resistor, so if nothing is connected, the input reads as high (1).
Which statement correctly describes the power limits of USB ports on a Raspberry Pi 4?
Think about the total power budget for USB devices connected to the Pi.
On Raspberry Pi 4, all USB ports share a combined current limit of about 1.2A total, not per port.
What will this Python code print when run on a Raspberry Pi connected to a 1920x1080 HDMI display?
import subprocess output = subprocess.run(['tvservice', '-s'], capture_output=True, text=True) print(output.stdout.strip())
Look for the resolution and refresh rate in the output string.
The tvservice command reports the current HDMI mode. For a 1920x1080 display at 60Hz, it shows the CEA mode with that resolution.
What error does this code raise when trying to set a GPIO pin high on a Raspberry Pi?
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.OUT) GPIO.output(17, 2)
Check the allowed values for GPIO.output() when setting pin state.
GPIO.output() expects the value to be 0 (low) or 1 (high). Passing 2 causes a ValueError.
How many general-purpose input/output (GPIO) pins are available on a Raspberry Pi 4 Model B for user programming?
Consider the total pins on the header and which are reserved for power or ground.
The Raspberry Pi 4 has a 40-pin header, but 26 of these are GPIO pins; the rest are power and ground pins.