If you have learned some languages like C, C++, Java, etc before then its good but if not then no problem as we just wanted you to know that there are blocks in the programs always, and these blocks like functions are differentiated from each other using some logics like in C and C++, we use curly braces(“{}“) but in Syntax Of Python, we use indentation.
So, now what is indentation?
Indentation is defined as the no. of white spaces that are used to define a specific area or block or region and this is a convention in python that every programmer should follow.
In computer programming, an indentation style is a convention governing the indentation of blocks of code to convey program structure.
Indentation is not a requirement of most programming languages, where it is used as a secondary notation. Rather, indenting helps better convey the structure of a program to human readers. Especially, it is used to clarify the link between control flow constructs such as conditions or loops, and code contained within and outside of them. However, some languages (such as Python and Occam) use indentation to determine the structure instead of using braces or keywords; this is termed the off-side rule. In such languages, indentation is meaningful to the compiler or interpreter; it is more than only a clarity or style issue.
“Hello World!” in C
Example
# include<stdio.h> int main(){ printf("Hello World!"); return 0; }
As you can see in the above example of C Language, where we are using the curly braces(“{}“) to define the “main” block and “;” i.e. semicolon to end any line.
“Hello World!” in Python
Example
print(Hello World!)
Here, in python language, we are using four white spaces to define the main function’s region or block which is called indentation and it’s usually four. This is one of the main differences between other languages and python.