Font size
WorksheetsException ✋
Total questions: 12
Worksheet time: 6mins
How many except statements can a try-except block have?
Zero
One
Two
Multiples
When will the else part of try-except-else be executed?
always
when an exception occurs
when no exception occurs
never
When is the finally block executed?
when an exception occurs
when no exception occurs
never
always
Can one except block handle multiple exceptions?
Yes
No
May be
Insufficient information
Which of the following is correct regarding exception
That may occur any time
That occurs before execution
That occurs after execution
That occurs during execution
ZeroDivisionError may occur during which operation
Division
Modulo
Both
None
Exception handling in python is done using ___ blocks
try
except
else
finally
Is the following Python code valid?
try:
# Do something
except:
# Do something
finally:
# Do something
Yes
No
Is the following code is vaild ?
try:
1 / 0
except:
print('exception')
else:
print('else')
finally:
print('finally')
Yess
No
Maybe
What is the output of the following code ?
try:
if '2' != 2:
raise ValueError
else:
print('same')
except ValueError:
print('ValueError')
except NameError:
print('NameError')
Value Error
Name Error
Both
None of the above
If there is an error in opening a file, which exception is raised ?
Index Error
IO Error
Import Error
Type Error
