Skip to content
dreamcode
dreamcode
Lesson
Practice · Concurrency
  1. Predict
  2. Arrange
  3. Fill in
+20 XP on finish
PREDICT · READ BEFORE YOU WRITE

What does this program print?

Trace the program the way the computer would, then make your call before running 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())