A block is a set of statements that are all executed as a unit. Generally, statements that are to be executed based on the condition or in a loop, are kept in blocks. The header of block ends with a colon (:) and the statements within the block are indented. When we get out of the indent, it identifies the end of the block.
Syntax:
Example:
Here in this code the first two print statements will be executed depending upon the condition given in ‘if()’ statement. The third print statement will be executed irrespective of the result of the condition since it is out of the block.