Create a flash card for every exception in Python with an explanation of each.
(75 cards)
What is the base class for all exceptions in Python?
BaseException
True or False: The Exception class is a subclass of BaseException.
True
What exception is raised when an invalid operation is performed on a data type?
TypeError
Fill in the blank: The _______ exception is raised when an index is not found in a list.
IndexError
What exception is raised when a variable is referenced before it has been assigned?
UnboundLocalError
What type of error does a ValueError represent?
It represents an operation or function receiving an argument that has the right type but an inappropriate value.
What exception is raised when trying to access a key that does not exist in a dictionary?
KeyError
True or False: A ZeroDivisionError occurs when dividing by zero.
True
What exception is thrown for operations that exceed the limits of a data type?
OverflowError
Fill in the blank: The _______ exception is used to indicate that a function is not implemented.
NotImplementedError
What exception is raised when a file operation fails?
IOError
What exception is raised when an import statement fails to find the module?
ImportError
True or False: The AssertionError is raised when an assert statement fails.
True
What exception occurs when an attempt is made to access an attribute that does not exist?
AttributeError
What exception is raised when a floating point operation results in a value that cannot be represented?
FloatingPointError
Fill in the blank: The _______ exception is raised when an operation is attempted on a closed socket.
socket.error
What exception is raised when a function receives an invalid argument?
TypeError
What exception is raised when an operation on a string is attempted that is not allowed?
ValueError
True or False: The NameError is raised when a local or global name is not found.
True
What exception is raised when a method is called on an object of an inappropriate type?
AttributeError
Fill in the blank: The _______ exception is raised when a numerical calculation exceeds the maximum limit for a numeric type.
OverflowError
What exception is raised for an invalid operation in a generator?
StopIteration
What exception is raised when there is an issue with the underlying operating system?
OSError
True or False: The RuntimeError is raised when an error is detected that doesn’t fall under any other category.
True