Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Netligent Exception

Total questions: 18

Worksheet time: 10mins

Name
Class
Date
1.

Exception disrupts the

a)

Normal flow of the program

b)

Abnornal flow of the program

c)

Hard Disk

d)

None of the Above

2.

The suspicious code is put inside the

a)

Try Block

b)

Finally Block

c)

Else Block

d)

Except Block

3.

________ statement can also be used without specifying Exception.

a)

Try

b)

Finally

c)

Except

d)

Else

4.

try:

a=10/5

print (a)

except ArithmeticError:

print ("This statement is raising an exception" )

finally:

print (" final block executed " )

a)

2.0

final block executed

b)

This statement is raising an exception

final block executed

c)

final block executed

d)

2.0

5.

An exception can be manually triggered by the command

a)

raise

b)

try

c)

except

d)

trigger

6.

User defined Exceptions are created from the _________ Parent Class

a)

Exception

b)

Except

c)

Handler

d)

User Defined Exception

7.

How many except statements can a try-except block have?

a)

zero

b)

one

c)

more than one

d)

more than zero

8.

When will the else part of try-except-else be executed?

a)

a) always

b)

b) when an exception occurs

c)

c) when no exception occurs

d)

d) when an exception occurs in to except block

9.

Is the following Python code valid?


try:

# Do something

except:

# Do something

else:

# Do something

a)

no, there is no such thing as else

b)

no, else cannot be used with except

c)

no, else must come before except

d)

yes

10.

What will be the output of the following Python code?


lst = [1, 2, 3]

lst[3]

a)

a) NameError

b)

b) ValueError

c)

c) IndexError

d)

d) TypeError

11.

How many except statements can a try-except block have?

a)

Zero

b)

One

c)

More than One

d)

More than Zero

12.

When is the finally block executed?

a)

when an exception occurs

b)

when no exception occurs

c)

never

d)

always

13.

Can one except block handle multiple exceptions?

a)

Yes

b)

No

c)

May be

d)

Insufficient information

14.

Which of the following is correct regarding exception

a)

That may occur any time

b)

That occurs before execution

c)

That occurs after execution

d)

That occurs during execution

15.

Exception handling in python is done using ___ blocks

a)

try

b)

except

c)

else

d)

finally

16.

What is the output of the attached python code?

a)

Value error

Finally done

b)

Type error

Finally done

c)

Type error

d)

Value error

17.

What is the output of the attached python code?

a)

Function name error

Sum finally

Invocation finally

b)

Invocation name error

Invocation finally

c)

Sum finally

Invocation name error

Invocation finally

d)

Function name error

Sum finally

18.

What is the output of the attached python code?

a)

100

b)

0

c)

Zero Division Error Occurred

d)

Another error will occur, program will "crash"