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

A program runs `text = "LOUD"` and then `quiet = text.lower()`. What happens?

  1. Both names refer to `loud` after an in-place change.
  2. `quiet` is `None`, and `text` becomes `loud`.
  3. Calling `lower` raises TypeError on immutable text.
  4. `quiet` is `loud`, and `text` remains `LOUD`.الإجابة الصحيحة

الشرح

The method creates the lowercase string for `quiet` while the original immutable string stays unchanged under `text`. Expecting an in-place edit mistakes the returned string for a mutation of the receiver.

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

بدء التدريب
السؤال 20: A program runs `text = "LOUD"` and then `quiet =… · Python Fundamentals · Questena