Bird
0
0

Find the error in this code:

medium📝 Debug Q7 of 15
Raspberry Pi - GPIO Basics with Python
Find the error in this code:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(10, GPIO.OUT)
GPIO.output(10, 1)
GPIO.cleanup()
AUsing integer 1 instead of GPIO.HIGH in GPIO.output
BPin 10 is not valid in BOARD mode
CMissing GPIO.setwarnings(False) before setup
DNo error, code is correct
Step-by-Step Solution
Solution:
  1. Step 1: Check pin numbering and setup

    Pin 10 is valid in BOARD mode and set as output.
  2. Step 2: Check GPIO.output parameter

    GPIO.output accepts 1 as HIGH and 0 as LOW, so integer 1 is valid.
  3. Step 3: Confirm no missing required calls

    GPIO.setwarnings() is optional and not required here.
  4. Final Answer:

    No error, code is correct -> Option D
  5. Quick Check:

    Integer 1 accepted as HIGH = C [OK]
Quick Trick: GPIO.output accepts 0/1 or GPIO.LOW/HIGH [OK]
Common Mistakes:
  • Thinking only GPIO.HIGH allowed
  • Confusing pin numbering modes
  • Assuming setwarnings() is mandatory

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes