What is Debugging? Types of Errors

What is Debugging?

A programmer can make mistakes while writing a program, and hence, the program may not execute or may generate wrong output. The process of identifying and removing such mistakes, also known as bugs or errors, from a program is called debugging.

What is Debugging
What is Debugging

c

These are types of errors occurring in programs can be categorized as:

  1. Syntax Errors
  2. Logical Errors
  3. Runtime Error
Types of Errors
Types of Errors

Syntax Errors

Like other programming languages, Python has its own rules that determine its syntax. The interpreter interprets the statements only if it is syntactically (as per the rules of Python) correct. If any syntax error is present, the interpreter shows error message(s) and stops the execution there.

For example, parentheses must be in pairs, so the expression (10 + 12) is syntactically correct, whereas (7 + 11 is not due to the absence of the right parenthesis. Such errors need to be removed before the execution of the program.

Logical Errors

A logical error is a bug in the program that causes it to behave incorrectly. A logical error produces an undesired output but without abrupt termination of the execution of the program. Since the program interprets successfully even when logical errors are present in it, it is sometimes difficult to identify these errors.

The only evidence of the existence of logical errors is the wrong output. While working backward from the output of the program, one can identify what went wrong. Logical errors are also called semantic errors as they occur when the meaning of the program (its semantics) is not correct.

Runtime Error

A runtime error causes abnormal termination of program while it is executing. Runtime error is when the statement is correct syntactically, but the interpreter cannot execute it. Runtime errors do not appear until after the program starts running or executing.

For example, we have a statement having division operation in the program. By mistake, if the denominator entered is zero then it will give a runtime error like “division by zero”.


Leave a Reply