Exception Handling Questions and Answers

Take Exam

Python Programming - Exception Handling Questions with Answers teach how to manage runtime errors safely. These Python Exception Handling Questions are vital for Infosys, TCS, and RRB exams to test coding accuracy and fault tolerance

Exception Handling

Showing 10 of 25 questions

21. Which method is called when using the "with" statement for resource management?

  • start() and stop()
  • open() and close()
  • __enter__() and __exit__()
  • begin() and end()
Show Answer Report

22. What exception is raised when a file cannot be found?

  • IOError
  • FileError
  • FileNotFoundError
  • NotFoundError
Show Answer Report

23. How can you catch multiple exceptions in a single except block?

  • Using multiple except blocks for each
  • Using a tuple of exception types
  • Using the "multiple" keyword
  • It's not possible to catch multiple exceptions
Show Answer Report

24. What is the purpose of the traceback module?

  • To prevent exceptions
  • To handle exceptions automatically
  • To extract and print stack traces
  • To create new exceptions
Show Answer Report

25. Which exception is raised when there is an indentation error?

  • SyntaxError
  • IndentationError
  • FormatError
  • TabError
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test