| 1. |
How many except statements can a try-except block have?
|
||||||||
|
Answer:
Option (d) |
| 2. |
When will the else part of try-except-else be executed?
|
||||||||
|
Answer:
Option (c) |
| 3. |
Is the following Python code valid?
try:
# Do something
except:
# Do something
finally:
# Do something
|
||||||||
|
Answer:
Option (b) |
| 4. |
Is the following Python code valid?
try:
# Do something
except:
# Do something
else:
# Do something
|
||||||||
|
Answer:
Option (d) |
| 5. |
Can one block of except statements handle multiple exceptions?
|
||||||||
|
Answer:
Option (a) |
| 6. |
When is the finally block executed?
|
||||||||
|
Answer:
Option (d) |
| 7. |
What will be the output of the following Python code?
def foo():
try:
return 1
finally:
return 2
k = foo()
print(k)
|
||||||||
|
Answer:
Option (b) |
| 8. |
What happens when ‘1’ == 1 is executed?
|
||||||||
|
Answer:
Option (b) |
| 9. |
The following Python code will result in an error if the input value is entered as -5.
assert False, 'Spanish'
|
||||
|
Answer:
Option (a) |
| 10. |
Which of the following is not an exception handling keyword in Python?
|
||||||||
|
Answer:
Option (c) |