Python Quiz 1 – Exceptionally Crazy
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!
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?
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!
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. You should get the book if you’d like to see the answer to this quiz or one of the over one hundred other quizzes! The quiz book will be finished in March 2023. However, you can purchase early access to it on the following websites:
Or, if you’re a paid subscriber, keep reading to find out the answer to this quiz!
Keep reading with a 7-day free trial