exception handling exceptions are unexpected events that occur during the execution of program an exception might result from logical error or an unanticipated situation in pythonexceptions (also known as errorsare objects that are raised (or thrownby code that encounters an unexpected circumstance the python interpreter can also raise an exception should it encounter an unexpected conditionlike running out of memory raised error may be caught by surrounding context that "handlesthe exception in an appropriate fashion if uncaughtan exception causes the interpreter to stop executing the program and to report an appropriate message to the console in this sectionwe examine the most common error types in pythonthe mechanism for catching and handling errors that have been raisedand the syntax for raising errors from within user-defined blocks of code common exception types python includes rich hierarchy of exception classes that designate various categories of errorstable shows many of those classes the exception class serves as base class for most other error types an instance of the various subclasses encodes details about problem that has occurred several of these errors may be raised in exceptional cases by behaviors introduced in this for exampleuse of an undefined identifier in an expression causes nameerrorand errant use of the dot notationas in foo bar)will generate an attributeerror if object foo does not support member named bar class exception attributeerror eoferror ioerror indexerror keyerror keyboardinterrupt nameerror stopiteration typeerror valueerror zerodivisionerror description base class for most error types raised by syntax obj fooif obj has no member named foo raised if "end of filereached for console or file input raised upon failure of / operation ( opening fileraised if index to sequence is out of bounds raised if nonexistent key requested for set or dictionary raised if user types ctrl- while program is executing raised if nonexistent identifier used raised by next(iteratorif no elementsee section raised when wrong type of parameter is sent to function raised when parameter has invalid value ( sqrt(- )raised when any division operator used with as divisor table common exception classes in python