Python Exception Handling Quiz

Python Exception Handling Quiz

12th Grade

15 Qs

quiz-placeholder

Similar activities

Quiz Pemrograman Python

Quiz Pemrograman Python

10th Grade - University

15 Qs

Scratch intro

Scratch intro

4th Grade - University

14 Qs

Data Structures Quiz

Data Structures Quiz

9th - 12th Grade

14 Qs

Python Temel Konuları Testi

Python Temel Konuları Testi

10th Grade - University

20 Qs

Introduction To Programming - Lesson Exception Handling

Introduction To Programming - Lesson Exception Handling

11th Grade - University

13 Qs

G 10- Understanding Main Memory and Cache

G 10- Understanding Main Memory and Cache

10th Grade - University

11 Qs

9 Weeks Test

9 Weeks Test

9th - 12th Grade

16 Qs

Video Game Design - Quiz4 -L5 -P

Video Game Design - Quiz4 -L5 -P

9th - 12th Grade

10 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?