Built-in Exceptions in Python provide standard exceptions for common error types, such as AttributeError, EOFError, FloatingPointError, and more. The exceptions are raised automatically when errors occur to indicate the type of error. Some examples include AttributeError for failed attribute assignment, EOFError for hitting end-of-file, and FloatingPointError for failed floating point operations.
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
161 views
Built-In Exceptions in Python
Built-in Exceptions in Python provide standard exceptions for common error types, such as AttributeError, EOFError, FloatingPointError, and more. The exceptions are raised automatically when errors occur to indicate the type of error. Some examples include AttributeError for failed attribute assignment, EOFError for hitting end-of-file, and FloatingPointError for failed floating point operations.
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6
Built-in Exceptions in Python
• All instances in Python must be instances of a
class that derives from BaseException. • There are several built-in exceptions in Python that are raised when errors occur Exception Cause of Error Raised when attribute AttributeError assignment or reference fails. Raised when the input() EOFError functions hits end-of-file condition. Raised when a floating point FloatingPointError operation fails. Raised when the imported ImportError module is not found. Raised when index of a sequence IndexError is out of range. Raised when an error does not RuntimeError fall under any other category. Raised when a key is not found in KeyError a dictionary. Raised when the user hits KeyboardInterrupt interrupt key (Ctrl+c or delete). Raised when an operation runs MemoryError out of memory. Raised when a variable is not NameError found in local or global scope. NotImplementedError Raised by abstract methods. Raised when system operation OSError causes system related error. Raised when result of an OverflowError arithmetic operation is too large to be represented. Raised by next() function to StopIteration indicate that there is no further item to be returned by iterator. Raised by parser when syntax SyntaxError error is encountered. Raised when there is incorrect IndentationError indentation. Raised when interpreter detects SystemError internal error. SystemExit Raised by sys.exit() function. Raised when a function or TypeError operation is applied to an object of incorrect type. Raised when a reference is made to a local variable in a function or UnboundLocalError method, but no value has been bound to that variable. Raised when a function gets ValueError argument of correct type but improper value. Raised when second operand of ZeroDivisionError division or modulo operation is zero.