Question 1 of 25
Hints left: 3
Q1
What is the purpose of the sys.exc_info() function in Python?
Q2
What will be the output of the following Python code? def foo(): try: print(1) finally: print(2) foo()
Q3
Identify the type of error in the following Python codes? Print(“Good Morning”) print(“Good night)
Q4
Is the following Python code valid? try: # Do something except: # Do something finally: # Do something
Q5
What is the syntax to raise an exception manually in Python?
Q6
What is the purpose of the finally clause in a try block?
Q7
How can you catch and handle multiple exceptions in a single except block in Python?
Q8
What will be the output of the following Python code? def f(x): yield x+1 print("test") yield x+2 g=f(9)
Q9
What will be the output of the following Python code? def getMonth(m): if m<1 or m>12: raise ValueError("Invalid") print(m) getMonth(6)
Q10
What is the purpose of the except clause without specifying an exception type in a try block?
Q11
What is the purpose of the else clause in a try block?
Q12
What will be the output of the following Python code? def f(x): yield x+1 print("test") yield x+2 g=f(10) print(next(g)) print(next(g))
Q13
What happens when '1' == 1 is executed?
Q14
Which of the following is not a standard Python exception?
Q15
What will be the output of the following Python code? int('65.43')
Q16
Which of the following is not a standard exception in Python?
Q17
What is the purpose of the else clause in a try block?
Q18
How can you create a custom exception class in Python?
Q19
What is the output of the following code: try: x = 10 / 0 except ZeroDivisionError: print("Error!") finally: print("Finally!")
Q20
What will be the output of the following Python code? g = (i for i in range(5)) type(g)
Q21
How can you catch and handle multiple exceptions in a single except block in Python?
Q22
Which of the following statements is true regarding the order of except clauses?
Q23
An exception is . . . . . . . .
Q24
Which of the following is not an exception handling keyword in Python?
Q25
What is the syntax to raise an exception manually in Python?