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 :

print("Hello World")


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 :

if(10 > 9) :
     print("Condition is true")

print("Hello")

The output for the above code:

Condition is true
Hello

Now, Lets give a condition which will return false and then check the output.

if(10 > 15) :
     print("Condition is true")

print("Hello")


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:

if(10 > 15) :
print("Condition is true")

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 :

if(10 > 5) :
  print("Condition is true")
if(10 > 5) :
     print("Condition is true")

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.