Is the following code is vaild ?
try:
1 / 0
except:
print('exception')
else:
print('else')
finally:
print('finally')
How many except statements can a try-except block have?
When is the finally block statements executed?
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')
What is the output of the following code ?
try:
print('try')
except ValueError:
print('ValueError')
finally:
print('finally')
When does the else part of try-except-else be executed ?
What is the output of the following code ?
a = 20
b = 30
assert b - a , 'a is smaller than b'
print(b)
If there is an error in opening a file, which exception is raised ?
Which of the following is not a standard exception in Python ?
What is the output of the following code ?
list1 = [4, 5, 6]
print(list1[4])