Python Tutorial: Types of Errors in Python - Syntax, Runtime, Logical, Built-in Exceptions
Syntax Error or parsing error which occurs when the code is not written as per Python language rules. The python interpreter halts and reports the error without executing the program.
Runtime Error or exception and this occurs when the program is run. Even if a statement or expression is syntactically correct, it may cause an error when an attempt is made to execute it. Interpreter runs the program but halts at the error and reports the error as an “Exception”.
Another type of error is Semantic or Logical. Interpreter runs the program but does not report an error. This occurs when the program runs but does not work expectedly and does not give the desired output.
Errors are a normal part of coding and they are bound to happen with every coder, sooner or later. So these are the errors in python language which we have to watch out for.
A number of built-in exceptions or run-time errors are defined in the Python library. Exceptions come in different types, and the type is printed as part of the message. Let's see some common exceptions.
1. ZeroDivisionError
2. NameError
3. IndexError
4. TypeError
5. ValueError
6. ModuleNotFoundError
7. KeyError
8. ImportError
Step by step process with examples
Practice by writing the code yourself.
Python Tutorial For Beginners • Python Tutorial for Beginners
Python New Releases And Latest Features • Python New Releases And Latest Features
#Python #Tutorials #Gurgaon
#Exceptions #Errors #Syntax #Parsing #Runtime #Semantic #Logical
#ZeroDivisionError #NameError #IndexError #TypeError #ValueError #ModuleNotFoundError #KeyError #ImportError
#Python3 #Gurgaon #Coding #Classes #Gurugram #Programming #Beginner #Tutorial