Quiz de Python: Output-Based Python Questions

Many Python interviews hand you a snippet and ask "what does this print?". This quiz is ten of those, each mixing two ideas such as rebinding vs mutation, slicing with steps, sort keys or exhausted generators.

Médio 10 perguntas ~6 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?

a = [1]
b = a
a = a + [2]
c = [1]
d = c
c += [2]
print(b, d)
Mostrar a resposta

A. [1] [1, 2] a + [2] builds a new list and rebinds a, so b still points to the old [1]. c += [2] extends the list in place, and d is that same list, so it shows [1, 2].

O que este quiz cobre

  • a = a + [x] vs a += [x]
  • Slicing with steps and negative steps
  • Dict comprehensions with repeated keys
  • Sort keys that use tuples
  • Generators that can only be used once

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.