English

“Every syntax error is an exception but every exception cannot be a syntax error.” Justify the statement. - Computer Science (Python)

Advertisements
Advertisements

Question

“Every syntax error is an exception but every exception cannot be a syntax error.” Justify the statement.

Answer in Brief

Solution

Exception is an error which occurs at Run Time, due to Syntax Errors, Run Time Errors or Logical Errors. In Python Exceptions are triggered automatically. It can be called forcefully also by using the code.

Syntax Error means errors occurs at compile time, due to not followed the rules of Python Programming Language. These errors are also known as parsing errors. On encountering a syntax error, the interpreter does not execute the program unless we rectify the errors, save and rerun the program. When a syntax error is encountered while working in shell mode, Python displays the name of the error and a small description about the error.

Because Exception can be occurred due to Syntax Errors, Logical Error and Run Time Errors, while Syntax errors occurs only due to syntax. So that “Every syntax error is an exception but every exception cannot be a syntax error.”

shaalaa.com
Syntax Errors
  Is there an error in this question or solution?
Chapter 1: Exception Handling in Python - Exercise [Page 17]

APPEARS IN

NCERT Computer Science [English] Class 12
Chapter 1 Exception Handling in Python
Exercise | Q 1. | Page 17
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×