What is Syntax?

 

What is Syntax?

In simplest words, Syntax is the arrangement of words and phrases to create well-formed sentences in a language. In the case of a computer language, the syntax is the structural arrangement of comments, variables, numbers, operators, statements, loops, functions, classes, objects, etc. which helps us understand the meaning or semantics of a computer language.

 

For E.g. a ‘comment’ is used to explain the functioning of a block of code. It starts with a ‘#’.

More on comments in the comments chapter.

 

For E.g. a block of code is identified by an ‘indentation’. Have a look at the following code, here print(i) is said to be indented with respect to the link above it. In simple words, indentation is the addition of spaces before the line "print(i)"


for i in range(5):
    print(i)