QuestenaUn entraînement qui indique quoi revoir ensuite
Question 49

In one `if`, `elif`, `else` chain, both the `if` condition and an `elif` condition are truthy. Which suite executes?

  1. Only the suite under the first truthy `if` conditionBonne réponse
  2. Both the `if` and `elif` suites
  3. Only the `elif` suite
  4. The `if` suite followed by the `else` suite

Explication

The chain selects the first truthy condition, executes its suite, and skips all later alternatives. Running the `elif` suite as well would treat mutually exclusive branches as independent `if` statements.

Continuer avec ce test

Commencer l’entraînement
Question 49: In one `if`, `elif`, `else` chain, both the `if` condition… · Python Fundamentals · Questena