1.3 Debugging: Programming is error-prone. Programming errors are called bugs and the process of identifying and removing errors from a program is called debugging.
Three kinds of errors can occur in a program:
1.Syntax errors
2.Runtime errors
3.Semantic errors
It is useful to distinguish between them in order to track them down more quickly.
Syntax errors:
Python can only execute a program if the syntax is correct otherwise the interpreter displays an error message.
Syntax refers to the structure of a program and the rules about that structure.
For example, parentheses have to come in matching pairs,
so print(“Hello World”) is legal but print(“Hello World” is a syntax error.
Runtime errors:
The second type of error is a runtime error. Run time errors are detected during the execution of a program. These errors are also called exceptions. When exception occurs the program stops the normal execution and terminates abruptly
For example, division by zero is not defined in mathematics which can lead to arithmetic exception
Semantic errors:
The third type of error is the semantic error. If there is a semantic error in our program, it will run successfully in the sense that the computer will not generate any error messages, but it will not do the right thing. It will do something else.
No comments:
Post a Comment