In this lecture, I would like to talk about coding books, so why we need coding blocks, code books
are used to group together lines of code that has the same purpose, like in case of which we use which
to decide the color of the car and printed out a text based on that.
So what coding books are by definition, they are zero or more statements enclosed embraces, but it
can be a for loop.
And if statement a class or something else with curly braces, we are going to see some letters for
code blocks and see how variables can be accessed in and outside of a code.
OK, all right, let's do this.
A code block has a starting curly brace and an ending curly brace, and the code that belongs to it
is between the braces.
We can also have situations when we have a code lock in another one, we have a blue and a red here,
the red code block, and before the blue one, let's see a concrete example for this.
We can have a for loop with an if statement in it for loop block wraps the if statement and if block
is part of the four block.
Now, let's move on to variable access, the best way to explain this is by using an example.
So we have two blocks here, an inner and outer.
If you create a variable outside of the red block, you can still access it in the red block and you
can even modify it by the end of this code, the number of the owners will be six.
Now, let's take another example when you define a variable in the red.
So now the number of the owner is variable in the red, but we would like to access it outside of the
red.
The problem is that after the red block is ended, that variable stopped existing.
So we get an error if we would like to use that.
We call these type of variables local variables, there are other types of variables like class variables
that will be covered later in the course.
That's all about code blocks.
It was a shorter one.
Now, let's move on to the coding part.