Commonly occurring exceptions are usually defined in the compiler/interpreter. These are called built-in exceptions.
Python’s standard library is an extensive collection of built-in exceptions that deals with the commonly occurring errors (exceptions) by providing the standardized solutions for such errors. On the occurrence of any built-in exception, the appropriate exception handler code is executed which displays the reason along with the raised exception name. The programmer then has to take appropriate action to handle it. Some of the commonly occurring built-in exceptions that can be raised in Python are explained in Table.
Built-in exceptions in Python


Figure shows the built-in exceptions viz, ZeroDivisionError, NameEError, and TypeError raised by the Python interpreter in different situations.
Example of built-in exceptions

A programmer can also create custom exceptions to suit one’s requirements. These are called user-defined exceptions. We will learn how to handle exceptions in the next section.