QuestenaÜben und erkennen, was als Nächstes dran ist
Frage 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`.Richtige Antwort

Erklärung

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.

Mit diesem Test weitermachen

Übung starten
Frage 20: A program runs `text = "LOUD"` and then `quiet =… · Python Fundamentals · Questena