QuestenaUn entraînement qui indique quoi revoir ensuite
Question 56

Which description of `x < y <= z` is accurate?

  1. It means `x < y` or `y <= z`.
  2. It means `x < y` and `x <= z`.
  3. It requires `x < y` and `y <= z`, with one evaluation of `y`.Bonne réponse
  4. It is invalid syntax because comparisons cannot be chained.

Explication

The chain requires both neighboring comparisons to hold and evaluates the middle expression only once. Comparing `x` directly with `z` for the second test changes the meaning, while writing two separate comparisons can reevaluate `y`.

Continuer avec ce test

Commencer l’entraînement
Question 56: Which description of `x < y <= z` is accurate? · Python Fundamentals · Questena