Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
+1 vote
159 views
in Python by (117k points)
retagged by
Python Built-in Exceptions are pre-defined errors that occur during the execution of a Python program. Some of the most commonly searched keywords related to Python Built-in Exceptions include "exception handling in Python", "Python try-except", "built-in exception types in Python", and "Python exception hierarchy". Understanding how to handle and work with exceptions in Python is a crucial skill for any programmer. By familiarizing yourself with the built-in exception types in Python, you can write more robust code and handle errors effectively. This article will cover the basics of Python Built-in Exceptions, including what they are, how they work, and some common examples of their usage.

Please log in or register to answer this question.

1 Answer

+1 vote
by (117k points)
edited by

Python Built-in Exceptions

Here is a list of Python Built-in Exceptions with a brief explanation of each:

  • BaseException: The base class for all built-in exceptions.
  • Exception: The most general class of exceptions.
  • ArithmeticError: The base class for those built-in exceptions that are raised for various arithmetic errors.
  • BufferError: Raised when a buffer related operation cannot be performed.
  • LookupError: The base class for exceptions raised when a key or index is not found in a mapping or sequence.
  • AssertionError: Raised when an assert statement fails.
  • AttributeError: Raised when an attribute reference or assignment fails.
  • EOFError: Raised when the input() function hits an end-of-file condition (EOF) without reading any data.
  • FloatingPointError: Raised when a floating point operation fails.
  • GeneratorExit: Raised when a generator or coroutine is closed.
  • ImportError: Raised when an import statement fails to find the module definition or when a from ... import fails to find a name that is to be imported.
  • IndexError: Raised when an index is out of range.
  • KeyError: Raised when a mapping (dictionary) key is not found in the set of existing keys.
  • KeyboardInterrupt: Raised when the user hits the interrupt key (normally Ctrl-C or Delete).
  • MemoryError: Raised when an operation runs out of memory.
  • NameError: Raised when a local or global name is not found.
  • NotImplementedError: Raised by abstract methods that have not been implemented in a subclass.
  • OSError: Raised when a system-related operation fails.
  • OverflowError: Raised when an arithmetic operation exceeds the maximum representable value.
  • ReferenceError: Raised when a weak reference proxy is used to access a garbage-collected referent.
  • RuntimeError: Raised when an error occurs that does not belong to any other category.
  • StopAsyncIteration: Raised by an asynchronous iterator's anext() method to signal the end of the iteration.
  • StopIteration: Raised by an iterator's next() method to signal the end of the iteration.
  • SyntaxError: Raised when there is an error in Python syntax.
  • IndentationError: Raised when the indentation is not correct.
  • TabError: Raised when the indentation contains a mixture of tabs and spaces.
  • SystemError: Raised when the interpreter detects an internal error.
  • SystemExit: Raised by the sys.exit() function to terminate the program.
  • TypeError: Raised when an operation or function is applied to an object of inappropriate type.
  • UnboundLocalError: Raised when a reference is made to a local variable in a function or method, but no value has been bound to that variable.
  • UnicodeError: Raised when a Unicode-related error occurs.
  • UnicodeEncodeError: Raised when a Unicode-related error occurs during encoding.
  • UnicodeDecodeError: Raised when a Unicode-related error occurs during decoding.
  • UnicodeTranslateError: Raised when a Unicode-related error occurs during translation.
  • ValueError: Raised when a built-in operation or function receives an argument that has the right type but an inappropriate value.
  • ZeroDivisionError: Raised when the second operand of a division or modulo operation is zero.

Related questions

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...