Bird
0
0

Which code correctly implements this?

hard📝 Application Q8 of 15
Agentic AI - Agent Safety and Guardrails
You want to design a workflow where AI automatically approves if confidence >= 0.8, requests human approval if confidence is between 0.5 and 0.8, and rejects otherwise. Which code correctly implements this?
Aif confidence >= 0.8: print('Auto-approved') elif 0.5 <= confidence < 0.8: print('Request human approval') else: print('Rejected')
Bif confidence > 0.8: print('Auto-approved') elif confidence > 0.5: print('Request human approval') else: print('Rejected')
Cif confidence >= 0.8: print('Auto-approved') if confidence > 0.5: print('Request human approval') else: print('Rejected')
Dif confidence >= 0.8: print('Auto-approved') else: print('Request human approval') else: print('Rejected')
Step-by-Step Solution
Solution:
  1. Step 1: Understand the conditions

    Auto-approve if confidence >= 0.8, human approval if 0.5 <= confidence < 0.8, else reject.
  2. Step 2: Check code logic

    if confidence >= 0.8: print('Auto-approved') elif 0.5 <= confidence < 0.8: print('Request human approval') else: print('Rejected') uses if, elif, else with correct ranges and prints matching outputs.
  3. Final Answer:

    Option A correctly implements the workflow -> Option A
  4. Quick Check:

    Use if-elif-else with correct ranges [OK]
Quick Trick: Use if-elif-else for multiple confidence ranges [OK]
Common Mistakes:
  • Using multiple ifs instead of elif causing multiple prints
  • Wrong comparison operators or missing ranges
  • Syntax errors with multiple else blocks

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes