What is exception? Name 5 common exceptions?
An exception can be defined as an abnormal condition in
a program resulting in the disruption in the flow of the program. Whenever an
exception occurs, the program halts the execution, and thus the further code is
not executed. Therefore, an exception is the error which python script is
enable to tackle with.
Python provides us with the way to handle the exception so
that the other part of the code can be executed without any disruption. However,
if we do not handle the exception, the interpreter does not execute all the
code that exists after that.
5 COMMON EXCEPTIONS:-
1.ZeroDivisionError:-Occurs when a number is divided by zero.
2.NameError:-It occurs when a name is not found. It may be
local or global.
3.IndentationError:-If incorrect indentation is given.
4.IOError:-It occurs when input output operation fails.
5.EOFError:-It occurs when the end of the file is reached, and
yet operations are being performed.