Quick Print – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
siteicon
Solved Problem Solved Problem#PYTHON#6088

Problem Statement - B01A

Differentiate between Syntax Error and Run-Time Error? Also, write a suitable example in Python to illustrate both.

Solution

Syntax error : An error of language resulting from code that does not conform to
the syntax of the programming language.
Example

a = 0
while a < 10 # : is missing as per syntax
    a = a + 1
    print a

Runtime error : A runtime error is an error that causes abnormal termination of
program during running time..
Example

A=10
B= int(raw_input("Value:"))
print A/B
# If B entered by user is 0, it will be run-time error