Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to run two tools in parallel using asyncio.
Agentic AI
import asyncio async def run_tools(): task1 = asyncio.create_task(tool1()) task2 = asyncio.create_task([1]) await task1 await task2
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same tool function twice.
Not calling the function (missing parentheses).
Awaiting tasks before creating both.
✗ Incorrect
We create a task for tool2() to run it in parallel with tool1().
2fill in blank
mediumComplete the code to gather results from two parallel tool executions.
Agentic AI
import asyncio async def run_tools(): results = await asyncio.gather(tool1(), [1]) return results
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Repeating the same tool twice.
Forgetting parentheses to call the function.
Using a non-async function.
✗ Incorrect
asyncio.gather runs tool1() and tool2() concurrently and collects their results.
3fill in blank
hardFix the error in the code to run tools in parallel and collect results.
Agentic AI
import asyncio async def run_tools(): tasks = [tool1, [1]] results = await asyncio.gather(*[task() for task in tasks]) return results
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including parentheses in the tasks list.
Mixing function calls and references.
Passing non-callable objects.
✗ Incorrect
The tasks list should contain function references without parentheses to call them later.
4fill in blank
hardFill both blanks to create tasks for three tools and run them concurrently.
Agentic AI
import asyncio async def run_tools(): task1 = asyncio.create_task(tool1()) task2 = asyncio.create_task([1]) task3 = asyncio.create_task([2]) await asyncio.gather(task1, task2, task3)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same tool multiple times.
Missing parentheses in function calls.
Not awaiting all tasks together.
✗ Incorrect
Create tasks for tool2() and tool3() to run all three tools in parallel.
5fill in blank
hardFill all three blanks to run tools in parallel and collect their results in a dictionary.
Agentic AI
import asyncio async def run_tools(): results = await asyncio.gather(tool1(), [1], [2]) return {"tool1": results[0], [3]: results[1], "tool3": results[2]}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect keys in the dictionary.
Forgetting parentheses in function calls.
Mixing up the order of results.
✗ Incorrect
Run tool2() and tool3() in parallel with tool1(), then map results to keys 'tool2' and 'tool3'.