Bird
0
0

Given the code below, what will be printed if sensor_value = 75?

medium📝 Predict Output Q13 of 15
Raspberry Pi - Automation and Scheduling
Given the code below, what will be printed if sensor_value = 75?
def check_sensor(value):
    if value > 70:
        print("Alert: High sensor value!")
    else:
        print("Sensor value normal.")

check_sensor(sensor_value)
AAlert: High sensor value!
BNo output
CSensor value normal.
DSyntaxError
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the condition with sensor_value = 75

    Since 75 > 70, the if condition is true.
  2. Step 2: Determine which print statement runs

    The code prints "Alert: High sensor value!" because the if condition is met.
  3. Final Answer:

    Alert: High sensor value! -> Option A
  4. Quick Check:

    75 > 70 triggers alert print [OK]
Quick Trick: Check if condition true or false to find printed message [OK]
Common Mistakes:
MISTAKES
  • Confusing else output with if output
  • Assuming no output if condition true
  • Thinking code has syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes