Question 1
What is the purpose of the 'try' block in python exception handling?
Question 2
What is the purpose of the 'pass' statement in exception handling?
Question 3
Which of the following is NOT a standard python exception?
Question 4
What will happen if an exception is raised inside a 'finally' block?
Question 5
What will be the output of the following code?
try:
  x = 10 / 0
except ZeroDivisionError:
  print("Division by zero", end=", ")
finally:
  print("Finally block")
Question 6
Which exception is raised when you try to access a key that does not exist in a dictionary?
Question 7
Which of the following is a built-in exception in python for handling division by zero?
Question 8
Which keyword is used to re-raise an exception in python?
Question 9
Which of the following is not a valid way to handle exceptions in python?
Question 10
What will happen if no exception is raised in the try block of a try-except block?
Question 11
What is the purpose of the 'else' block in exception handling?
Question 12
Which of the following is a correct way to open a file in python that ensures proper cleanup?
Question 13
What will be the output of the following code?
try:
  x = 10 / 0
except ZeroDivisionError:
  print("Division by zero")
except ArithmeticError: Â Â
  print("Arithmetic error")
Question 14
How can you handle multiple exceptions in a single 'except' block?
Question 15
What is the purpose of the assert statement in python?
Question 16
What does the 'else' block in a try-except do?
Question 17
What is the output of the following code?
try:
  x = 10 / 0
except ZeroDivisionError as e:
  print(e)
Question 18
How can you create a custom exception class in python?
Question 19
What is the purpose of the 'sys.exc_info()' function in python?
Question 20
What is the output of the following code?
try:
  x = int("hello")
except ValueError:
  print("Invalid conversion") Â
Question 21
Which of the following statements is true regarding custom exceptions in python?
Question 22
What is the purpose of the 'with' statement in python file handling?
Question 23
What is the order of exception handling in a try-except block with multiple except blocks?
Question 24
Which of the following is a proper way to close a file after reading its contents using a 'with' statement?
Question 25
Which exception is raised when you try to open a file that does not exist in python?
Question 26
What does the assert statement do when it raises an exception?
Question 27
Which keyword is used to specify a block of code that should be executed regardless of whether an exception is raised or not?
Question 28
In python, which statement is used to specify the code that should be executed if no exceptions are raised?
Question 29
Which of the following is true about the 'finally' block in python exception handling?
Question 30
What is the purpose of the 'assert' statement in python?
Question 31
Which of the following is a valid way to handle exceptions in python?
Question 32
Which exception is raised when you try to access a variable that is not defined?
Question 33
What is the purpose of the 'except' block in python?
Question 34
What is the purpose of the 'try' block in exception handling?
Question 35
What does the 'sys.exc_info()' function return in python?
Question 36
Which keyword can be used to catch multiple exceptions in a single except block?
Question 37
What is the purpose of the 'finally' block in exception handling?
Question 38
What does the 'finally' block in python guarantee?
Question 39
What is an exception in python?
Question 40
Which of the following is a common use case for the finally block in exception handling?
Question 41
Which of the following is not a valid exception handling construct in python?
Question 42
Which keyword is used to raise an exception in python?
Question 43
Which of the following is a common use case for the 'assert' statement in python?
Question 44
In a try-except block, what happens if an exception is raised inside the try block?
Question 45
What is the purpose of the 'assert' statement in python?
Question 46
Which keyword is used to raise an exception in python?
Question 47
Which of the following is true about the 'assert' statement in python?
Question 48
What is the primary role of the 'else' block in python exception handling?
Question 49
Which exception is raised when you try to access an element of a list using an index that is out of range?
Question 50
Which of the following is a common exception handling best practice?