QuestionQ19

Exception Handling

What is the output of the following commands entered in the Python Interactive shell?

Question Image

  • A Try Else Except Finally
  • B Try Finally
  • C Try
  • D Try Else Finally
Explanation

Because the try block completes without raising an exception, Python executes the else block and skips except. The finally block executes regardless of whether an exception occurred, so the output is Try Else Finally.

Community Discussion

No comments yet. Be the first to start the discussion!