Bird
0
0

Given this code snippet, what will be printed?

medium📝 Predict Output Q5 of 15
Raspberry Pi - Automation and Scheduling

Given this code snippet, what will be printed?

moisture = 300
threshold = 400
if moisture < threshold:
    print("Pump ON")
else:
    print("Pump OFF")

APump ON
BPump OFF
CError: invalid syntax
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Compare moisture value with threshold

    300 is less than 400, so condition is true.
  2. Step 2: Determine which print statement runs

    Since condition is true, "Pump ON" is printed.
  3. Final Answer:

    Pump ON -> Option A
  4. Quick Check:

    Condition true = Pump ON printed [OK]
Quick Trick: If moisture below threshold, pump turns ON [OK]
Common Mistakes:
MISTAKES
  • Confusing less than with greater than
  • Expecting syntax error due to < entity
  • Thinking no output occurs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes