The Python programming language allows you to catch exceptions using the try / except construct. But what happens if you nest exception handlers and throw in a break statement too?

Your mission in this quiz is to find the answer to that question!

The Quiz

Are you ready to start solving quizzes? Of course, you are!

Here’s your first one:

What will be output if you run this code?

A) Outer ZeroDivisionError exception caught B) Error: You divided by zero! C) Error: You divided by zero! Finally executed D) Finally executed E) None of the above

When you are ready, flip to the answer section of this book and check your answer!

Hint

If you’re stuck, try reading about Python’s break statement. It’s not normally used in exception handling.

The Python Quiz Book

This quiz comes from my latest book, The Python Quiz Book. If you’d like to see the answer to this quiz or one of the over one hundred other quizzes, you should get the book! The quiz book will be finished in March 2023. However, you can purchase early access to it on the following websites:

Gumroad
Leanpub

The post Python Quiz 1 – Exceptionally Crazy appeared first on Mouse Vs Python.

Categories: Python