Questenaتدريب يوضح لك ما ينبغي مراجعته لاحقًا
السؤال 17

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

  1. `b` is `sunset`, while `a` remains `sun`.الإجابة الصحيحة
  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.

الشرح

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.

تابع هذا الاختبار

بدء التدريب
السؤال 17: After `a = "sun"` and `b = a + "set"`, which statement is… · Python Fundamentals · Questena