Bird
0
0

Consider this simple system:

medium📝 Analysis Q13 of 15
AI for Everyone - What is Artificial Intelligence
Consider this simple system:
rules = {'hot': 'turn_on_ac', 'cold': 'turn_on_heater'}
def apply_rule(temp):
    if temp > 25:
        return rules['hot']
    else:
        return rules['cold']
print(apply_rule(30))

What will this print?
AError
Bturn_on_heater
Cnull
Dturn_on_ac
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the input and condition

    Input temperature is 30, which is greater than 25, so the 'hot' rule applies.
  2. Step 2: Determine the returned action

    The function returns rules['hot'], which is 'turn_on_ac'.
  3. Final Answer:

    turn_on_ac -> Option D
  4. Quick Check:

    Temp 30 > 25 -> 'turn_on_ac' [OK]
Quick Trick: Check condition then pick matching rule [OK]
Common Mistakes:
MISTAKES
  • Choosing 'turn_on_heater' ignoring condition
  • Assuming function returns null
  • Thinking code causes error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AI for Everyone Quizzes