Random Types of Errors
Random Types of Errors
ERRORS
• An error ,sometimes called ‘a bug’ is anything
in the code that prevents a program from
compiling and running correctly.
There are 3 types of errors
• Compile time errors
• Run time errors
• Logical errors
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.
i)Syntax errors: Syntax errors occur when rules of a
programming language are misused.
Example:
for i in range(6)
print(“hi’)
ii)Semantics Errors: Semantics Errors occur when
statements are not meaningful.
Semantics refers to the rules which give the
meaning of a statement.
Example:x+y=r
RUN TIME ERRORS
• Errors that occur during the execution of a program are run
time errors.
• These are harder to detect errors.
• 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 encounters them.
Example:
infinite loop
abnormally terminated
LOGICAL ERRORS
Sometimes ,even if you dont encounter any
error during compile-time and run-time ,
program does not provide the correct result.
(i) 10#40#70#
(ii) 30#40#50#
(iii) 50#60#70#
(iv) 40#50#70#
import random
text="CBSEONLINE"
count=random.randint(0,3)
c=9
while text[c]!='L':
print(text[c]+text[count]+"*",end="")
count=count+1
c=c-1
i)EC*NB*IS*
ii)NS*IE*LO*
iii)ES*NE*IO*
iv)EE*NO*IN
import random
high=4
guess=random.randint(0,high)+50
for c in range(guess,56):
print(c,end=“#”)
i)50#51#52#53#54#55#
ii)52#53#54#55
iii)53#54#
iv)49#50#51#52#53#54#55#
import random
AR=[20,30,40,50,60,70]
Lower =random.randint(1,3)
Upper =random.randint(2,4)
for K in range(Lower, Upper +1):
print (AR[K],end=”#“)