Python-Quiz: Tricky Python Questions

This hard Python quiz is full of snippets that look simple but behave in surprising ways. It covers equal dict keys, operator precedence, nan, empty iterables, class scope and other traps interviewers love to ask about.

Schwer 10 Fragen ~8 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?

d = {True: "a", 1: "b", 1.0: "c"}
print(d)
Lösung zeigen

C. {True: 'c'} True == 1 == 1.0 and they have the same hash, so all three are the same key. The first key object (True) is kept, while each later assignment replaces the value, ending with 'c'.

Darum geht es in diesem Quiz

  • Dict keys that are equal, like True, 1 and 1.0
  • Operator precedence with ** and unary minus
  • When a generator expression reads its names
  • nan, all([]) and other edge cases
  • Changing a dict while looping over it, and class body scope

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.