Bird
0
0

Why is it important to use callbacks instead of polling the button state in Raspberry Pi programs?

hard📝 Conceptual Q10 of 15
Raspberry Pi - gpiozero Library

Why is it important to use callbacks instead of polling the button state in Raspberry Pi programs?

ACallbacks respond instantly without wasting CPU resources
BPolling is faster and more efficient than callbacks
CCallbacks require more CPU and slow down the program
DPolling automatically debounces the button
Step-by-Step Solution
Solution:
  1. Step 1: Compare callbacks and polling

    Polling repeatedly checks button state, using CPU even when idle.
  2. Step 2: Benefits of callbacks

    Callbacks run only when button is pressed, saving CPU and responding quickly.
  3. Final Answer:

    Callbacks respond instantly without wasting CPU resources -> Option A
  4. Quick Check:

    Callbacks = efficient event-driven response [OK]
Quick Trick: Callbacks save CPU by running only on events [OK]
Common Mistakes:
  • Thinking polling is more efficient
  • Believing callbacks slow program
  • Assuming polling debounces automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes