Oct-02-2019, 01:45 PM
Hi!
Sorry for bothering you with this probably stupid question, but I can get really stuck with some little non-vital doubts.
If I understand program blocks correctly, the blocks have the same indentation level, inside a program, so if a program is just a list of print commands like:
Therefore, in a program like the following (I've used blank lines to better clarify which ones are the blocks with coloured rectangles):
![[Image: program-blocks-02.png]](https://i.postimg.cc/hG2Pv20J/program-blocks-02.png)
I think there are 4 code blocks:
1) The whole program, that I've named BLOCK A (the yellowish block).
2) The big pinkish block that I've named BLOCK B (that is inside BLOCK A).
3) The greenish block that I've named BLOCK C (that is inside BLOCK B, being this one also, inside BLOCK A).
4) The purplish block that I've named BLOCK D (that is inside BLOCK B, being this one also, inside BLOCK A).
But according to the book I saw it in, the author considers that there are only 3 blocks, the ones that I have coloured pinkish, greenish and purplish, and not considering the whole program as a bigger, outer block.
Am I wrong?
Sorry again for bothering you with this probably inconsequential question.
All the best,
Sorry for bothering you with this probably stupid question, but I can get really stuck with some little non-vital doubts.
If I understand program blocks correctly, the blocks have the same indentation level, inside a program, so if a program is just a list of print commands like:
print("Hello!") print("This is a probably stupid question.") print("Of course it is, you dimwit!")I understand that this program consists of only one block of code.
Therefore, in a program like the following (I've used blank lines to better clarify which ones are the blocks with coloured rectangles):
![[Image: program-blocks-02.png]](https://i.postimg.cc/hG2Pv20J/program-blocks-02.png)
I think there are 4 code blocks:
1) The whole program, that I've named BLOCK A (the yellowish block).
2) The big pinkish block that I've named BLOCK B (that is inside BLOCK A).
3) The greenish block that I've named BLOCK C (that is inside BLOCK B, being this one also, inside BLOCK A).
4) The purplish block that I've named BLOCK D (that is inside BLOCK B, being this one also, inside BLOCK A).
But according to the book I saw it in, the author considers that there are only 3 blocks, the ones that I have coloured pinkish, greenish and purplish, and not considering the whole program as a bigger, outer block.
Am I wrong?
Sorry again for bothering you with this probably inconsequential question.
All the best,