Recall & Review
beginner
What is an exception in Python?
An exception is an error that happens during the running of a program, which stops the normal flow of the program.
Click to reveal answer
beginner
Name a common reason why exceptions occur.
Exceptions often occur because the program tries to do something invalid, like dividing by zero or accessing a missing file.
Click to reveal answer
beginner
What happens if an exception is not handled?
If an exception is not handled, the program will stop running and show an error message.
Click to reveal answer
beginner
Why might a 'FileNotFoundError' exception occur?
This exception happens when the program tries to open a file that does not exist or the path is wrong.
Click to reveal answer
beginner
How does Python signal that an exception has occurred?
Python raises an exception object that interrupts the normal flow and looks for code to handle it.
Click to reveal answer
What causes a ZeroDivisionError in Python?
✗ Incorrect
Dividing by zero is not allowed and causes a ZeroDivisionError.
What happens if you do not handle an exception?
✗ Incorrect
Uncaught exceptions stop the program and display an error message.
Which of these is NOT a reason for exceptions?
✗ Incorrect
Correct code like a print statement does not cause exceptions.
What does Python do when an exception occurs?
✗ Incorrect
Python raises an exception object to signal the error.
Why might a FileNotFoundError happen?
✗ Incorrect
Trying to open a file that does not exist causes FileNotFoundError.
Explain in your own words why exceptions occur in Python programs.
Think about what happens when the program tries to do something it cannot.
You got /4 concepts.
List some common examples of exceptions and why they happen.
Recall errors like dividing by zero or missing files.
You got /4 concepts.