Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial →
← CoursesSenior Deep-DivesModule 3 · Metaclasses, Descriptors, Magicasyncio internals: event loop step-by-steppredict42 / 161
+150 XP
Task
📝 **Question:** Predict the exact output. Three coroutines run via \`asyncio.gather\`: A prints 3 times, B prints 3 times, C prints 2 times. Between prints, each yields via \`asyncio.sleep(0)\`. In what order do the prints fire? 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.
Predict the output

Read the code carefully

import asyncio


async def loop_task(name, n):
    for i in range(n):
        print(f"{name}:{i}")
        await asyncio.sleep(0)


async def main():
    await asyncio.gather(loop_task("A", 3), loop_task("B", 3), loop_task("C", 2))


asyncio.run(main())

What will the program print? Write here:

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…