Skip to content
dreamcode
dreamcode
Back to lesson
Practice · Py-concurrency
PredictArrangeFill in
+20 XP on finish
PREDICT · READ BEFORE YOU WRITE

What does this program print?

Read the program like the computer would, then call the output before you run anything.

import asyncio

async def star_task(name, delay):
    await asyncio.sleep(delay)
    return name

async def main():
    t1 = asyncio.create_task(star_task("Sirius", 0.2))
    t2 = asyncio.create_task(star_task("Vega", 0.1))
    await asyncio.sleep(0.15)
    print(t1.done(), t2.done())

asyncio.run(main())