QuesAns Print Page – CSKC
Sign In

Search

siteicon
Q&A CBSE12A-2018-B01A #6088

Question:

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

Answer:

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