0% found this document useful (0 votes)
11 views2 pages

Errors in Python

Uploaded by

somakgulati
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)
11 views2 pages

Errors in Python

Uploaded by

somakgulati
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/ 2

Errors

An error is a problem that occurs in a program. Error sometimes halt the program execution, or produce
unexpected results, and cause the program to behave abnormally.
Syntax error
Logical error
Runtime error

Syntax Error

Syntax are the rules for framing statements in aprogramming language. Any violations in the rules while
writing a program are known as Syntax Erors. They prevent the code from executing and are detected by
the Python interpreter before the execution of the program begins.
Some of the Common Syntax Errors are
Parenthesis Mismatch
Misspelled keyword
Incorrect Indentation

Logical Error
Logical errorsoccur when the code runs without any errors, but the output is not as expected. Logical errors
are caused by a problem in the logic of the code.
Example: Average = mark 1+ mark 2/2 # incorrect calculation of average marks
Corrected Code : Average = (mark1 + mark 2)/2

Runtime Error
Aruntime error causes abnormal termination of the program during the execution. Runtime error occurs
when the statement is correct syntactically, but the interpreter cannot execute it.

Example: 'division by zero'

num1= 5.0
num2 = int (input("num2 =")) #if the user inputs zero, a runtime error
will occur
print (numl/num2)

You might also like