Bird
0
0

You want to display the average sensor value over the last 5 readings on a Raspberry Pi dashboard. Which approach is best?

hard📝 Scenario Q8 of 15
Raspberry Pi - Web Server and API
You want to display the average sensor value over the last 5 readings on a Raspberry Pi dashboard. Which approach is best?
APrint each reading without storing history
BCalculate average once at startup and never update
CUse only the latest reading as the average
DStore last 5 readings in a list, then calculate average each update
Step-by-Step Solution
Solution:
  1. Step 1: Understand averaging over recent readings

    To average last 5 readings, you must store them in a list or buffer.
  2. Step 2: Evaluate options for updating average

    Calculating once or using only latest reading ignores new data; printing without storing can't average.
  3. Final Answer:

    Store last 5 readings in a list, then calculate average each update -> Option D
  4. Quick Check:

    Rolling average needs stored recent data [OK]
Quick Trick: Keep recent readings in a list to compute rolling average [OK]
Common Mistakes:
MISTAKES
  • Calculating average only once
  • Using single reading as average
  • Not storing readings for averaging

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes