wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Exceptions - Python Study Guide

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What will this code print?

a)

Was not defined

b)

NameError

c)

val3

d)

3

2.

What does "try" do in Python

a)

Attempt the code

b)

Run code if a condition is fulfilled

c)

Save a program

d)

Stop the code from running

3.

What does this code print?

a)

Was not defined

b)

3

c)

9

d)

NameError

4.

What does this code print?

a)

9

b)

Was not defined

c)

err0Rrr

d)

TypeError

5.

What does "finally" do in Python

a)

Run code after a "try" no matter what

b)

Run code at the end of the program

c)

Add code to program

d)

Help control errors

6.

What does this code print?

a)

None

b)

Yeah ! Your answer is: 1

c)

Sorry ! You are dividing by zero

d)

Yeah ! Your answer is: 4

7.

What does "else" do in a "try" block in Python?

a)

Run code after the block if nothing triggers

b)

Execute code if no exception happens

c)

Run code after try block

d)

Create 3 errors

8.

What does this code do?

a)

Print("An exception flew by!")

b)

print("An exception flew by!")

c)

print("An exception flew by!")

NameError('HiThere')

d)

NameError('HiThere')

9.

What does 'raise' do?

a)

Create an error

b)

Runs a line of code if a condition is fulfilled

c)

Run a code even if errors happen

d)

Stop the program

10.

What is 'except as'?

a)

Runs a line of code if a error happens

b)

Makes a variable to store errors

c)

Removes errors

d)

Runs a line of code if a error happens for a specific variable