In this blog, I will give you the basic but important information regarding the Exceptions in Python.
As we all know, we always get some Errors and Exceptions in program every now and then, so to know what that exception is all about. We should know all about exception.
So, let's dive into it.
First of all, let's
understand what Exception is?
If a
statement or expression is syntactically correct, it may cause an error when an
attempt is made to execute it. This errors detected during execution are called Exceptions.
Example:-
Exceptions are of different types and this error message indicates what happened.
Like you
see here in example i.e. ZeroDivisionError, NameError, TypeError. These are
basic errors in the program.
List of Standard
Exception :-
- Exception - Base Class for all the exception
- Stop Iteration - Raised when the next() method of an iterator does not point to any object.
Example :- - System Exit - Raised by the sys.exit() function.
- Standard Error - Base Class for all the built-in exceptions except Stop Iteration and SystemExit.
- ArithmeticError - Base Class for all errors that occur for numeric calculation.
- OverFlowError - Raised when a calculation exceeds a maximum limit for a numeric type.
Example:- - FloatingPointError - Raised when a floating point calculation fails. Floating point exception handling is not standardized, so floats are not checked. Regular integer are converted to long values are needed.
- ZeroDivisionError - Raised when division or modulo by zero takes place for all numeric types.
Example:- - AssertionError - Raised in case of failure of the Assert Statement.
Example :- - AttributeError - Raised in case of failure of attribute reference or assignment.
Example :-
These are some of the exceptions that generally occurred during the programming. There are some other exception that we will cover in our next post.
Hope this help, guys. Stay tune for next blog.
Comments
Post a Comment