What is code block ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

What is code block ?

12th Jun 2018, 1:23 PM
sam
sam - avatar
6 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.
12th Jun 2018, 2:17 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 5
code block is code that will be executed
12th Jun 2018, 1:51 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 5
In Python all the indented stuff following a line that ends in a colon is a code block.
13th Jun 2018, 9:00 AM
David Ashton
David Ashton - avatar
+ 3
Code block is just bunch of statements wrap inside curly braces. Examples : Functions. Loops. Logical Statement.
12th Jun 2018, 2:45 PM
Meet Mehta
Meet Mehta - avatar
+ 1
Indented lines under a function or module
27th Jun 2018, 3:59 PM
Ganesh DHARMALINGAM
Ganesh DHARMALINGAM - avatar
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!
13th Jun 2018, 5:07 AM
ifl
ifl - avatar