Bird
0
0

What will be the output of this code snippet?

medium📝 Predict Output Q4 of 15
Raspberry Pi - GPIO Basics with Python
What will be the output of this code snippet?
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
print(GPIO.gpio_function(7))

Assuming pin 7 is set as input by default.
A1 (GPIO.OUT)
B2 (GPIO.SPI)
C0 (GPIO.IN)
DRaises an error
Step-by-Step Solution
Solution:
  1. Step 1: Understand GPIO.gpio_function

    This function returns the current mode of the pin (input, output, etc.).
  2. Step 2: Default pin mode for BOARD pin 7

    Pin 7 defaults to input mode, which is represented by 0 (GPIO.IN).
  3. Final Answer:

    0 (GPIO.IN) -> Option C
  4. Quick Check:

    Default pin mode = GPIO.IN (0) [OK]
Quick Trick: Default pin mode is input (0) unless set otherwise [OK]
Common Mistakes:
  • Assuming pin defaults to output
  • Expecting error without setup call

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes