QuestenaUn entraînement qui indique quoi revoir ensuite
Question 96

Which statement correctly distinguishes else and finally in a try statement?

  1. Else needs an exception-free try; finally runs on either outcome.Bonne réponse
  2. Else handles exceptions that no except clause matches.
  3. Finally runs only when an exception occurs.
  4. Else and finally have interchangeable conditions.

Explication

The else suite is reserved for the path where the try suite raises no exception, while finally runs as control leaves the construct on either outcome. Treating else as an unmatched-exception handler or finally as exception-only erases their different roles.

Continuer avec ce test

Commencer l’entraînement
Question 96: Which statement correctly distinguishes else and finally in… · Python Fundamentals · Questena