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