Code Blocks
In computing, a block or code block is a syntactic structure of code where one or more declarations and statements are grouped together.
The function of blocks in programming is to enable groups of statements to be treated as if they were one statement, and to narrow the lexical scope of variables, procedures and functions are
declared in a block so that they do not conflict with variables having the same name used elsewhere in a program that have different purposes.
In Python indentation is the method of creating a code block
Exercise
Explain what a code block is in terms of a procedural language and give an example in python.
Extension questions:
- What happens if the indentation in a code block is incorrect give an example?
- Explain how a compound statement can also be a code block?