Exception Handling Questions and Answers

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
1. What is the purpose of exception handling in Python?
  • To terminate the program immediately when an error occurs
  • To handle errors gracefully and continue program execution
  • To ignore all errors in the program
  • To make the program run faster
Show Answer Report
2. Which keyword is used to handle exceptions in Python?
  • catch
  • throw
  • try-except
  • handle
Show Answer Report
3. What is the base class for all exceptions in Python?
  • Exception
  • BaseException
  • Error
  • BaseError
Show Answer Report
4. Which exception is raised when a variable is not found?
  • VariableError
  • NotFoundError
  • NameError
  • UndefinedError
Show Answer Report
5. What does the "finally" block do in exception handling?
  • Executes only when no exception occurs
  • Executes only when an exception occurs
  • Always executes regardless of exceptions
  • Never executes
Show Answer Report
6. Which exception is raised when dividing by zero?
  • DivisionError
  • MathError
  • ZeroDivisionError
  • ArithmeticError
Show Answer Report
7. What is the purpose of the "else" clause in try-except blocks?
  • Executes when an exception occurs
  • Executes only if no exception occurs in try block
  • Always executes
  • Executes before the try block
Show Answer Report
8. How can you raise an exception manually in Python?
  • throw
  • raise
  • exception
  • trigger
Show Answer Report
9. Which exception is raised when accessing a non-existent list index?
  • KeyError
  • IndexError
  • ListError
  • RangeError
Show Answer Report
10. What does the "except Exception as e" syntax do?
  • Catches all exceptions and stores in e
  • Catches only Exception class and stores in e
  • Ignores all exceptions
  • Raises a new exception
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test