Skip to main content

Practice ยท 1 of 2

Concurrent vs Sequential

Implement async def slow_double(n) awaiting asyncio.sleep(0.1) and returning n*2. Then async def run_concurrent(values) using asyncio.create_task for each value and awaiting all tasks. Provide sync wrapper run_all(values) returning the list of results (in input order).

Difficulty: intermediate

Back to lesson: Practice: Task Concurrency Drills