Font size
WorksheetsPYTHON EXCEPTION
Total questions: 13
Worksheet time: 7mins
The unexpected event happened during program execution should be handled by
EXCEPTION
EXPERIMENT
ASSERTION
EXTRAORDINARY
try:
a=int(input("\n Enter a Value"))
b=int(input("\n Enter a Value "))
c=a/b
print (c)
except:
print("\n Something Went Wrong")
Assume a = 10 and b = 5, then the output will be
5.0
Something Went Wrong
Arithmetic Error
2.0
Exception disrupts the
Normal flow of the program
Abnornal flow of the program
Hard Disk
None of the Above
The suspicious code is put inside the
Try Block
Finally Block
Else Block
Except Block
________ statement can also be used without specifying Exception.
Try
Finally
Except
Else
try:
a=10/5
print (a)
except ArithmeticError:
print ("This statement is raising an exception" )
finally:
print (" final block executed " )
2.0
final block executed
This statement is raising an exception
final block executed
final block executed
2.0
An exception can be manually triggered by the command
raise
try
except
trigger
User defined Exceptions are created from the _________ Parent Class
Exception
Except
Handler
User Defined Exception
How many except statements can a try-except block have?
zero
one
more than one
more than zero
When will the else part of try-except-else be executed?
a) always
b) when an exception occurs
c) when no exception occurs
d) when an exception occurs in to except block
Is the following Python code valid?
try:
# Do something
except:
# Do something
else:
# Do something
no, there is no such thing as else
no, else cannot be used with except
no, else must come before except
yes
What will be the output of the following Python code?
lst = [1, 2, 3]
lst[3]
a) NameError
b) ValueError
c) IndexError
d) TypeError
What will be the output of the following Python code?
lst = [1, 2, 3]
lst[3]
a) NameError
b) ValueError
c) IndexError
d) TypeError
