0% found this document useful (0 votes)
79 views19 pages

Types of Errors

This document discusses debugging and types of errors in computer programs. It defines debugging as locating errors, determining the cause, and fixing code. There are three types of errors: compile time, runtime, and logical errors. Compile time errors occur during compilation and include syntax errors from invalid grammar and semantics errors when statements are meaningless. Runtime errors happen during execution, sometimes crashing programs. Logical errors result from flawed logic like incorrect formulas. Exceptions differ from errors in that they represent anticipated events like dividing by zero rather than bugs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views19 pages

Types of Errors

This document discusses debugging and types of errors in computer programs. It defines debugging as locating errors, determining the cause, and fixing code. There are three types of errors: compile time, runtime, and logical errors. Compile time errors occur during compilation and include syntax errors from invalid grammar and semantics errors when statements are meaningless. Runtime errors happen during execution, sometimes crashing programs. Logical errors result from flawed logic like incorrect formulas. Exceptions differ from errors in that they represent anticipated events like dividing by zero rather than bugs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

COMPUTER

SCIENCE
DEBUGGING
&
TYPES OF ERRORS

CLASS – XI
What is
Debugging?
⚫ Debugging refers to the
process of locating the
place of error, cause of
error and correcting the
code accordingly.
⚫ Debugging means to
remove bugs from the
Bugs
⚫ An error causing disruption in
program’s running or in
producing right output is
known as a program bug.
Errors and Exceptions:-
⚫ Errors and Exceptions, both
disrupt a program and stop its
execution but they are not same.
What is an
Error?
⚫ An error, also known as a bug, is
any thing in the code that
prevents a program from
compiling and running correctly.
⚫ There are broadly three types of
errors:-
(i) Compile time errors
(ii) Run time errors
(iii) Logical errors
Compile Time
Errors:-
⚫ Errors that occur during compile
time, are compile time errors.
⚫ There are two types of compile
time error:-
(i) Syntax Error:
-
The errors that occur when
grammatical
rules of a programming language
are violated.
Compile Time
Errors:-
⚫ Examples of syntax errors:
PRINT(“welcome”)
The above statement will produce an
error as
print() function should be given in
lowercase
x=10
print(x)
The above statement will produce an
error as
ii)Semantics
Errors:-
⚫ Semantics errors are the errors
that occur when the statements are
not meaningful.
⚫ (Semantics refers to the set of rules
which give meaning to a statement)
⚫ For example:
X*Y=Z
10=y
will result in a semantics error as
an expression can not come to the
Logical
Errors:-
⚫ The errors that occur due to
incorrect logic such as
(wrong formula or wrong
operator), are known as
logical errors.
⚫ These errors occur when we
don't get the desired output
in a program.
⚫ These errors are most
Examples of Logical Errors:
-
⚫ Use of a variable before its
initialization
y=x+10 #x not declared
print(y)
⚫ wrong parameters passed to
a function.
⚫ Using wrong formula like:
Areaofrect=l+b
Errors:-
⚫ Errors that occur during the
execution of a program are
called run time errors.
⚫ Some run time errors stop the
execution of a program which
is known as abnormal
termination.
⚫ For example:
⚫ Number divided by zero[
⚫ Errors and exceptions are very
similar but have a slight
difference between them.
⚫ Errors represent any bug in the
code that disrupt running of a
program
whereas
⚫ an exception refers to any
-
⚫ Mathematical Exception
a=10
b=0
c=a/b
In simple terms
⚫ When you input wrong
PIN number in an ATM ,
it is an error.
Exceptions:-
⚫ If we try to open a
data file that does not
exist.
⚫ If we try to import a
module that does not
exist.
Some built in
Exceptions:-
⚫ ZeroDivisionError:- Raised when
the second argument of a division
or modulo operation is zero.
⚫ EOFError:- raised when input()
function reaches end of file
condition without reading data in
data files.
⚫ NameError :- raised when an
identifier name is not found.
⚫ ImportError:- Raised when an
Debugging using Code
Tracing:-
⚫ Most common technique to
debug an error is to find the
point of error and origin of
error.
⚫ Code Tracing is the most
useful debugging technique
⚫ Code tracing means
executing code one line at a
Debugging using Code
Tracing:-
⚫ One way of Code tracing
is DRY RUN that you
have already learnt.
⚫ Another way of code
tracing is using
Debugging tools
⚫ Python also has a
debugger tool for
TESTING is the process
of finding errors in a
program.

You might also like