Hello, guys, and welcome back.
We have talked a lot about conditional statements, I just want to show you the syntax to do that in
Python.
So the syntax is very simple.
So that does give a very simple example.
So eight equals five, B equals do and C equals then.
Now, this is only to show you the syntax of how you can use if statements, because we're going to
build on it when we progress with the course and build some larger applications.
So if I was a convert and B, I would say if A is larger than B and I would put a column like that,
I will press enter.
Now, here's the thing.
If you don't ever try to write on the line next to it without indentation, because this will give you
an error, what does an indentation it is a stab.
So you need to press a tap the tap button on your keyboard so that you can write under the F, but with
a little bit of a shift.
This is called indentation.
So everything is written here.
Let's say Brend.
A is larger than B.
Now, everything is under this vertical line will be part of the if statement.
OK, now how about what to do else?
Well, if it is written like this, ayliffe, let's say Ayliffe B is larger than a again column.
Make sure you are under the olive with an indentation, not here, but here, we're going to print B
is larger than A.
OK, now else, let's say if there is another case, Elif C is larger than a print, C is larger than
a.
OK, now finally we can say LTH.
Do the indentations, say print, no condition is satisfied.
OK, so let us compile and run.
OK, we have an error.
As you can see, it says syntax error, I intend to lead on this so that I can show you how the syntax
error is going to be shown.
It will see your syntax error, invalid syntax by else.
So we go to El's and we just add the call now again.
As you can see, it's sprinting is larger than this because it is here.
Now, if all of them let's say our one.
No condition is satisfied.
Well, I just want to show you something here, if I try and print another line here under the if like
this, but without indentation.
Let's say outsider.
As you can see, you will get an error because you are breaking the flow of statements, it should be
if indentation, then statement, then elusive indentation and statement, you cannot just put the line
right here.
This is wrong.
Again, I'm going to show you what happens.
Let's say if I delete this and I put the print right here.
Now, if I try.
As you can see, it will say indentation error expected and indented block.
So this is the end of the block they are talking about.
OK, this is a very important concept in Python.
And I wanted to show it to you because no other programming language depends and counts on indentation
and it's syntax except for Python.