QuestenaÜben und erkennen, was als Nächstes dran ist
Frage 17

After `a = "sun"` and `b = a + "set"`, which statement is correct?

  1. `b` is `sunset`, while `a` remains `sun`.Richtige Antwort
  2. Both `a` and `b` become `sunset`.
  3. The operation performs numeric addition after conversion.
  4. The operation raises TypeError because strings cannot use plus.

Erklärung

String addition creates the new value `sunset` and binds it to `b`; the immutable object referred to by `a` remains `sun`. The idea that the left operand grows in place would require mutable string contents, which Python does not provide.

Mit diesem Test weitermachen

Übung starten
Frage 17: After `a = "sun"` and `b = a + "set"`, which statement is… · Python Fundamentals · Questena