In Python programming, there are three types of errors that can occur. It is useful to recognize the different error types so they can be corrected more easily:
Syntax Error – occurs when the interpreter encounters code that does not conform to the Python language rules.
For example, a missing quote mark around a string. The interpreter halts and reports the error without executing the program.
Runtime Error – occurs during execution of the program, at the time when the program runs.
For example, when a variable name is later mistyped so the variable cannot be recognized. The interpreter runs the program but halts at the error and reports the nature of the error as an “Exception”.
Semantic Error – occurs when the program performs unexpectedly.
For example, when order precedence has not been specified in the expression. The interpreter runs the program and does not report an error.
Correcting syntax and runtime errors is fairly straightforward, as the interpreter reports where the error occurred or the nature of the error type, but semantic errors require code examination.