Debugging programs notes for class 11

Debugging programs notes for class 11


Debugging programs notes

for class 11



what is Debugging:-

Debugging refers to the process of locating the place of error. cause of error, and correcting the code accordingly.

Debugging programs notes for class 11

Errors and Exceptions:-

Errors and Exceptions, both disrupt a program and stop its execution. However, errors and exception are not the same.

let us first talk about errors and later we shall talk about exceptions.

errors in a program:-

an error, sometimes called ‘a bug’, is anything in the code that prevents a program from compiling and running correctly. some programs bugs are catastrophic in their effects, while others are comparatively less harmful and still others are so unclear that you will ever discover them. there are broadly three type of errors: compile-time errors, run-time errors and logical errors.

(i) Compile-time errors:

errors that occur during compile-time, are compile-time errors. when a program compiles, its source code is checked for whether it follows the programming language’s rules or not. Two types of errors fall into category of compile-time errors.

(a) Syntax errors:-

syntax errors occur when rules of programming language are misused i.e., when a grammatical rule python is violated.

for example, observe the following two statements:

       x<- y*x

       if x=(x*y)

these two statement will result in syntax errors as ‘<-‘ is not an assignment operator in python ‘=’ is assignment operator, not a relational operator.

also, if is a block statement, it require a colon (:) at the end of it, which is missing above.

correct statement is follows:

      x = y*x

      if x  == (x*y):

(b)Semantics errors:-

semantics errors occur when statements are not meaningful. for instance, the statement ‘Sita plays Guitar’ is syntactically correct (as the grammar is correct) but semantically incorrect. similarly, there are semantics rules of a programming language, violation of which results in semantical errors.

for instance, the statement


will result in a semantical error as an expression cannot come on the left side of an assignment statement.

(ii) Run-time Errors

errors that occur during the execution of a program are run-time errors. these harder to detect.

Some run-time errors stop the execution of the program which is then called program “crashed” or “abnormally terminated”.

most run-time errors are easy to identify because program halts when it encounter them e.g.,

an infinite loop or wrong value (of different data type other than required) is input.

(iii) logical errors:-

it occur when desired output not produced by program due to incorrect implementation of logic or logarithm.

Sometimes logical errors are treated as a subcategory of run-time errors.


an exception is an irregular unexpected situation which occur during execution of program on which program has no control.

let us try to understand the difference between an error and exception with the help of real life example.

for instance, if you operate an ATM then

  • entering wrong account number or wrong pin number is an ERROR.
  • ‘not that much amount in account’ is an EXCEPTION.
  • ‘ATM machine struck’ is also EXCEPTION.


Debugging programs notes for class 11


Debugging programs notes for class 11


How to DEBUG a program ?

Debugging involves correction of code so that the cause of errors is removed. But how do you know what are the errors? well, the compile time errors are caught during compilation and for logical errors, you perform testing. testing is done to verify correct behaviour i.e., with some sample values (test cases) is whose output is already known, the code is tested-if it produces the anticipated output, code is correct and if it is does not, there is some error. once you know the errors, you can debug your program.

Debugging techniques

debugging a program is a skill. there are many traditional debugging techniques that you can follow to debug your code. these are :

(1) carefully spot the origin of error.

(2) print variable’s intermediate values.

(3) code tracing and stepping.

Using Debugging tool:-

debugging tool or debugger is specialized software that can be used to test debug program. it can be integrated with IDE (integrated development Environment) like sublime.

python also provide a debugger program called as pdb(python debugger).

Break points:-

break point are temporary fault point or markers in program that stop the debugger at marked point.


pdb is a python debugger which can be used to trace or debug a python program with help of its commands.

Debugging programs notes for class 11

debugging programs important questions

download pdf of debugging programs

How to learn python for beginners ?