QuestenaPráctica que te muestra qué repasar después
Pregunta 17

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

  1. `b` is `sunset`, while `a` remains `sun`.Respuesta correcta
  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.

Explicación

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.

Continúa con este test

Empezar la práctica
Pregunta 17: After `a = "sun"` and `b = a + "set"`, which statement is… · Python Fundamentals · Questena