Bird
0
0

Given this Python code snippet for updating a dashboard:

medium📝 Predict Output Q13 of 15
Raspberry Pi - Web Server and API
Given this Python code snippet for updating a dashboard:
import time
sensor_value = 0
for _ in range(3):
    sensor_value += 5
    print(sensor_value)
    time.sleep(1)

What will be the printed output?
A5\n10\n15
B0\n5\n10
C5\n5\n5
D0\n0\n0
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the loop increments

    Initially, sensor_value = 0. Each loop adds 5, so values become 5, then 10, then 15.
  2. Step 2: Confirm printed values

    Each iteration prints the updated sensor_value, so output lines are 5, 10, and 15.
  3. Final Answer:

    5\n10\n15 -> Option A
  4. Quick Check:

    Increment by 5 each loop = 5,10,15 [OK]
Quick Trick: Add increments stepwise and print each [OK]
Common Mistakes:
MISTAKES
  • Printing before incrementing
  • Resetting sensor_value inside loop
  • Ignoring loop iterations count

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes