QuestenaUn entraînement qui indique quoi revoir ensuite
Question 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`.Bonne réponse

Explication

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.

Continuer avec ce test

Commencer l’entraînement
Question 20: A program runs `text = "LOUD"` and then `quiet =… · Python Fundamentals · Questena