+ 5
What is code block ?
8 Answers
+ 10
It is a wholesome logical piece of code, for example all set of instructions under an if statement or a for loop is considered a code block.
In Python, correct indentation of code blocks is vital to proper code flow.
+ 5
code block is code that will be executed
+ 5
In Python all the indented stuff following a line that ends in a colon is a code block.
+ 3
Code block is just bunch of statements wrap inside curly braces.
Examples :
Functions.
Loops.
Logical Statement.
+ 1
Indented lines under a function or module
0
In most modern language, a code block is a number of lines of code delimited by curly braces { }
In python, indentation is used instead.
You can have nested blocks, ie blocks within blocks.
(e.g., an if statement in a function)
in languages like java or c++, the scope of a variable defined within a block is limited to the block. The variable is not recognised outside of the block.
there is a good explanation here:
https://en.m.wikipedia.org/wiki/Block_(programming)
Happy coding!