Bird
0
0

What is wrong with this code snippet for error rate?

medium📝 Debug Q7 of 15
Agentic AI - Agent Observability
What is wrong with this code snippet for error rate?
total = 80
wrong = 8
error_rate = wrong / total
print(f"Error rate: {error_rate:.3f}")

Output is 0.100 but expected 10%. What is the issue?
AError rate is a decimal, not a percentage; multiply by 100 to get percent
BWrong and total variables are swapped
CFormatting with .3f is incorrect
DPrint statement missing percentage sign
Step-by-Step Solution
Solution:
  1. Step 1: Understand error rate output

    error_rate = 8 / 80 = 0.1 (decimal form)
  2. Step 2: Convert decimal to percentage

    Multiply by 100 to get 10%, which matches expectation.
  3. Final Answer:

    Error rate is a decimal, not a percentage; multiply by 100 to get percent -> Option A
  4. Quick Check:

    Decimal x 100 = percent [OK]
Quick Trick: Multiply decimal error rate by 100 for percent [OK]
Common Mistakes:
  • Expecting decimal as percent
  • Ignoring multiplication by 100

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes