Bird
0
0

How can you modify a content creation agent workflow to log each step's start and end times using Python's datetime module?

hard📝 Application Q9 of 15
Agentic AI - Real-World Agent Applications
How can you modify a content creation agent workflow to log each step's start and end times using Python's datetime module?
Aimport datetime for step in steps: start = datetime.datetime.now() process(step) end = datetime.datetime.now() print(f'{step} started at {start} and ended at {end}')
Bimport datetime for step in steps: process(step) print(f'{step} processed')
Cfor step in steps: start = time.now() process(step) end = time.now() print(f'{step} started at {start} and ended at {end}')
Dimport datetime for step in steps: start = datetime.now() process(step) end = datetime.now() print(f'{step} started at {start} and ended at {end}')
Step-by-Step Solution
Solution:
  1. Step 1: Use correct datetime import and method

    datetime.datetime.now() is the correct way to get current time.
  2. Step 2: Check code correctness

    import datetime for step in steps: start = datetime.datetime.now() process(step) end = datetime.datetime.now() print(f'{step} started at {start} and ended at {end}') imports datetime, uses datetime.datetime.now(), and logs times correctly.
  3. Final Answer:

    import datetime for step in steps: start = datetime.datetime.now() process(step) end = datetime.datetime.now() print(f'{step} started at {start} and ended at {end}') -> Option A
  4. Quick Check:

    Use datetime.datetime.now() for timestamps [OK]
Quick Trick: Use datetime.datetime.now() to get current time [OK]
Common Mistakes:
  • Using datetime.now() without module prefix
  • Using time.now() which does not exist
  • Not importing datetime module

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes