Bird
0
0

What is the main reason to invoke GPIO.cleanup() after your Raspberry Pi GPIO script finishes execution?

easy📝 Conceptual Q1 of 15
Raspberry Pi - GPIO Basics with Python
What is the main reason to invoke GPIO.cleanup() after your Raspberry Pi GPIO script finishes execution?
ATo permanently disable the GPIO pins
BTo speed up the execution of the next program
CTo reset all GPIO pins to their default state and avoid conflicts in future programs
DTo save the current GPIO pin states for later use
Step-by-Step Solution
Solution:
  1. Step 1: Understand GPIO states

    GPIO pins can remain set as input or output after a program ends.
  2. Step 2: Purpose of cleanup

    Calling GPIO.cleanup() resets pins to input mode, preventing interference with other programs.
  3. Final Answer:

    To reset all GPIO pins to their default state and avoid conflicts in future programs -> Option C
  4. Quick Check:

    Reset pins to default state [OK]
Quick Trick: Always reset GPIO pins after use [OK]
Common Mistakes:
  • Thinking cleanup speeds up code
  • Assuming cleanup disables pins permanently
  • Believing cleanup saves pin states

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes