Bird
0
0

What will be the output of this Python snippet controlling a water pump?

medium📝 Predict Output Q4 of 15
Raspberry Pi - Automation and Scheduling

What will be the output of this Python snippet controlling a water pump?

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
GPIO.output(18, GPIO.HIGH)
print(GPIO.input(18))

A1
B0
CGPIO.HIGH
DError: GPIO.input not allowed on output pin
Step-by-Step Solution
Solution:
  1. Step 1: Understand GPIO pin setup and output

    Pin 18 is set as output and set to HIGH (on).
  2. Step 2: Check GPIO.input reading on output pin

    GPIO.input returns 1 for HIGH state on output pin.
  3. Final Answer:

    1 -> Option A
  4. Quick Check:

    GPIO.input on HIGH output = 1 [OK]
Quick Trick: GPIO.input returns 1 for HIGH output pins [OK]
Common Mistakes:
MISTAKES
  • Expecting 0 instead of 1
  • Thinking input can't read output pin state
  • Confusing GPIO.HIGH with numeric output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes