Python-Quiz: 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.

Mittel 10 Fragen ~6 Minuten Bestanden ab 80% Python 3.12

Modus wählen

Du spielst als Gast: Melde dich an, damit XP und Serie gespeichert werden.

Beispielfrage

Frage 1 von 10

What does this print?

a = [1]
b = a
a = a + [2]
c = [1]
d = c
c += [2]
print(b, d)
Lösung zeigen

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].

Darum geht es in diesem Quiz

  • 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

Häufige Fragen

Brauche ich ein Konto?

Nein. Jeder kann spielen. Mit Anmeldung werden XP, Serie, Abzeichen und Verlauf gespeichert.

Welche Python-Version?

Python 3.12. Jede Frage zur Ausgabe wurde geprüft, indem der Code ausgeführt wurde.

Kann ich es wiederholen?

Ja. Dein Bestwert bleibt erhalten, und Fragen und Antworten werden jedes Mal neu gemischt.