0
0
Pythonprogramming~5 mins

Why exceptions occur in Python - Quick Recap

Choose your learning style9 modes available
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?
AUsing a variable before defining it
BDividing a number by zero
CTrying to open a missing file
DWriting invalid syntax
What happens if you do not handle an exception?
AThe program stops and shows an error
BThe program continues normally
CThe program ignores the error silently
DThe program restarts automatically
Which of these is NOT a reason for exceptions?
ACorrectly writing a print statement
BDividing by zero
CUsing a variable that is not defined
DTrying to access a missing file
What does Python do when an exception occurs?
AIgnores it
BAutomatically fixes the error
CRaises an exception object
DRestarts the program
Why might a FileNotFoundError happen?
AFile has wrong permissions
BFile is too large
CFile is open in another program
DFile path is incorrect or file is missing
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.