Python Syntax
In Python, You don't have to write any syntax to start writing a program. You can directly start writing your program on the line no 1.
Below is an example of a Hello world program in python :
Python does not require a semi-colon at the end of the line. We don't use semi-colon (;) in python.
For loops and conditional statements, there is no open and close parentheses"{}". There scope of the statement is defined by the indentation of the lines.
Example :
The output for the above code:
Condition is true Hello
Now, Lets give a condition which will return false and then check the output.
The output for the above code:
Hello
If the indentation is not proper, your code will not execute, as it is an error in python.
Example:
The above code will throw an error saying "Expected an indented block"
You can give any number of space for the indentation with a minimum of one space.
Example :
In the above code, both are correct and will give the same output.
The output for the above code:
Condition is true
Condition is true
Note : Number of space inside a block should be the same.