What is the difference between a coroutine object and a running task?

Python & APIsFoundations & codingAbout 9 minutes

Understand the idea, explain it in your own words and use the rubric to find your next learning gap.

Local drafts · no account or AI calls
Sukoaa original

The idea behind the question

Calling an async function creates a coroutine object; awaiting it or scheduling it drives execution. Task ownership determines who waits, cancels and observes failures.

AN ILLUSTRATIVE EXAMPLE

A developer creates several async document requests but forgets to await them before the program exits.

TRY A SMALL EXAMPLEPython · standard library
import asyncio

async def work(name):
    await asyncio.sleep(0)
    return name

async def main():
    tasks = [asyncio.create_task(work(name)) for name in ["research", "coding"]]
    results = await asyncio.gather(*tasks)
    print(results)

asyncio.run(main())
Show expected output
['research', 'coding']
Open Python playground

Copy and paste to run in a separate tab. This example illustrates one concept; it is not a complete application or an automatically graded task.

A practical way to learn it

Run the task example and explain why the printed result order is not evidence of completion order. Then add a deliberate exception and inspect it.

Open Python playground

The related tool opens separately; your interview answer stays here. Written practice is self-guided, without automatic code grading.

Build an explanation you understand

  1. State what the concept does in plain language.
  2. Apply it to the example and make your assumptions explicit.
  3. Explain a trade-off, failure case and how you would test it.
  4. Distinguish your actual experience from a proposed approach.

Further reading

Further-reading links support learning; the reference is Sukoaa-authored, not an official employer answer key.