Quiz de Python: asyncio Basics

This Python quiz covers the basics of asyncio and async/await. You will trace small coroutines step by step to see when code runs concurrently, what gather returns, and which mistakes block the event loop or never run at all.

Difícil 10 perguntas ~8 minutos Aprovação com 80% Python 3.12

Escolha um modo

Jogando como visitante: entre para guardar seu XP e sua sequência.

Pergunta de exemplo

Pergunta 1 de 10

What does this print?

async def greet():
    return "hi"

c = greet()
print(type(c).__name__)
c.close()
Mostrar a resposta

B. coroutine Calling an async def function does not run its body. It returns a coroutine object, which only runs when it is awaited or passed to something like asyncio.run.

O que este quiz cobre

  • Coroutine objects and asyncio.run
  • await in sequence vs asyncio.gather
  • How await asyncio.sleep(0) lets other tasks run
  • create_task and exceptions in gather
  • Why time.sleep blocks the event loop

Perguntas frequentes

Preciso de uma conta?

Não. Qualquer pessoa pode jogar. Entre para guardar seu XP, sequência, badges e histórico.

Qual versão do Python?

Python 3.12. Toda pergunta sobre a saída foi conferida rodando o código.

Posso refazer?

Pode. Sua melhor nota fica salva, e as perguntas e respostas são embaralhadas a cada vez.