Bird
0
0

Which condition correctly implements this logic in Python?

hard📝 Application Q15 of 15
Agentic AI - Agent Safety and Guardrails
You want to build a human approval workflow that requests approval only if the AI confidence is below 0.7 or if the task is marked as 'high risk'. Which condition correctly implements this logic in Python?
A<code>if confidence < 0.7 or task == 'high risk': request_approval()</code>
B<code>if confidence < 0.7 and task == 'high risk': request_approval()</code>
C<code>if confidence >= 0.7 or task != 'high risk': request_approval()</code>
D<code>if confidence > 0.7 and task == 'high risk': request_approval()</code>
Step-by-Step Solution
Solution:
  1. Step 1: Understand the logic needed

    Approval is requested if confidence is below 0.7 OR the task is 'high risk'. This means either condition triggers approval.
  2. Step 2: Match the correct Python condition

    The correct condition uses the 'or' operator to combine the two checks: confidence < 0.7 or task == 'high risk'.
  3. Final Answer:

    if confidence < 0.7 or task == 'high risk': request_approval() -> Option A
  4. Quick Check:

    Use 'or' for either condition triggering approval [OK]
Quick Trick: Use 'or' to combine conditions for approval [OK]
Common Mistakes:
  • Using 'and' instead of 'or' which requires both true
  • Reversing comparison operators
  • Confusing task string equality

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes