Bird
0
0

Given this code snippet measuring latency per step, what is the output of print(latencies)?

medium📝 Command Output Q13 of 15
Agentic AI - Agent Observability
Given this code snippet measuring latency per step, what is the output of print(latencies)?
latencies = []
for step in range(3):
    start = get_time()
    do_work(step)
    end = get_time()
    latencies.append(end - start)
print(latencies)
Assume do_work(step) takes 1, 2, and 3 seconds respectively.
A[1, 2, 3]
B[3, 2, 1]
C[0, 0, 0]
DError: get_time() undefined
Step-by-Step Solution
Solution:
  1. Step 1: Understand loop and timing

    Each loop iteration measures time before and after do_work(step).
  2. Step 2: Calculate latencies per step

    Since do_work takes 1, 2, and 3 seconds, latencies list will be [1, 2, 3].
  3. Final Answer:

    [1, 2, 3] -> Option A
  4. Quick Check:

    Latencies match step durations [OK]
Quick Trick: Latency list matches step durations in order [OK]
Common Mistakes:
  • Reversing latency order
  • Assuming zero latency
  • Ignoring step durations

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes