Computer Science, asked by raghav4711, 1 year ago

difference between syantax error and semantic error in python​

Answers

Answered by aliya346
4

hello

____________

1) Syntax errors. These are invalid code the compiler doesn't understand, e.g. your example of multiplying a string with an integer in C. The compiler will detect them, because it can't compile them.

2) Semantic errors. These are valid code the compiler understands, but they do not what you, the programmer, intended.

Answered by manaksia25
2

Syntax errors occur during the parsing of input code, and are caused by grammatically incorrect statements. Typical errors might be an illegal character in the input, a missing operator, two operators in a row, two statements on the same line with no intervening semicolon, unbalanced parentheses, a misplaced reserved word, etc.

Semantic errors occur during the execution of the code, after it has been parsed as grammatically correct. These have to do not with how statements are constructed, but with what they mean. Such things as incorrect variable types or sizes, nonexistent variables, subscripts out of range, and the like, are semantic errors.

Similar questions