Python Exception Handling Quiz

Python Exception Handling Quiz

12th Grade

15 Qs

quiz-placeholder

Similar activities

Review Time

Review Time

11th Grade - University

15 Qs

Kuis Dasar Koding dan AI

Kuis Dasar Koding dan AI

12th Grade

10 Qs

Arduino

Arduino

12th Grade

15 Qs

Quiz Assesmen Awal "Perangkat Keras"

Quiz Assesmen Awal "Perangkat Keras"

7th Grade - University

10 Qs

Quiz Komputasional-Struktur Data kelas 9

Quiz Komputasional-Struktur Data kelas 9

9th Grade - University

20 Qs

Basic Logic & Programming pt.2

Basic Logic & Programming pt.2

6th Grade - University

10 Qs

Pengenalan Profesi Bidang PPLG

Pengenalan Profesi Bidang PPLG

10th Grade - University

10 Qs

Understanding Code and Programming Concepts

Understanding Code and Programming Concepts

9th Grade - University

12 Qs

Python Exception Handling Quiz

Python Exception Handling Quiz

Assessment

Quiz

Information Technology (IT)

12th Grade

Hard

Created by

Ali Fakhri

FREE Resource

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What is the purpose of the try-except block in Python?

To import modules

To handle exceptions

To define a function

To create a loop

2.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Which exception is raised when a variable name is not found?

IndexError

ValueError

NameError

TypeError

3.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What does the finally block do in exception handling?

It terminates the program

It defines a new exception

It executes regardless of an exception

It executes only if an exception occurs

4.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Which of the following exceptions is raised when dividing by zero?

TypeError

IndexError

ValueError

ZeroDivisionError

5.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What will happen if an exception is not caught?

The program will crash

The program will continue running

The program will restart

The program will ignore the error

6.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Which exception is raised when trying to access an out-of-range index in a list?

IndexError

NameError

KeyError

AttributeError

7.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What is the output of the following code: 'x = 5; y = 'hello'; z = x + y'?

TypeError

None

Error: cannot add an int and a str

5hello

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?