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 example, 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 example, 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 line above it. In simple words, indentation is the addition of spaces before the line print(i)
.
for i in range(5):
print(i)