Afrikaans
Akan
Albanian
Amharic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Welcome back.
In this video, we are going to use if statements and we are going to finally make use of what we've
learned so far, for example, the comparison operators, which are very useful when it comes to if
statements.
So we had this comparison operator, we said five, equal equal three.
And then if that was true, we can now go ahead and execute something.
So now let's go ahead and create an if statement here.
And before we do so, I'm going to create a little variable called height person one and it's going
to be something like one hundred and seventy.
And then.
Maybe it should be written correctly and then I have another one white person, too, should be something
like one hundred and.
Eighty nine.
All right, so these are centimeters for those of you who aren't aware of what I'm talking about.
So one hundred and seventy centimeters and 189 centimeters, I think that's something like five.
Seven or five, eight or something like that.
And then this should be, um, six three in terms of feet and inches.
All right.
So these are the two person high person, one injured person, too.
So we have two people and we want to execute something based on a condition.
So if a person one is taller than person two.
Then we're going to use raw force in order to beat it.
Let's say we have a fight between two people and now we have to decide what kind of technique we want
to use.
So let's say our fighter is 170 and the opponent is one eighty nine.
So what should we do?
Shall we either use raw force or shall we use technique?
Of course, a combination of both will be useful, but then we're going to check if height person one
is greater than height.
Person two.
I simply want to print something like use raw force.
All right, so let's say let's assume that if someone is taller than he's also going to be stronger
because he's going to have more weight and that is going to be very useful in a one on one fight.
But now.
If we execute this line of code, we will see that pretty much nothing will happen because the condition
isn't met.
So we have this condition of high person.
One shall be created in high person, too.
But if you look at the values, we will see that that is not true because 170 isn't higher than one
eighty nine.
So we can see we get nothing here printed.
So now let's say the other way around, what should happen if a person one is less than hyd person too?
Well, that's something that we can use with an else statement.
OK, so in this case it's either if or else.
So if this condition is met, then execute the code that is within those curly brackets.
And if the condition is not met, then run the else block, which means run the code, which is within
those curly brackets.
So here I'm just going to say use technique.
All right.
So now let's run this again and see if anything will be printed whatsoever.
And we can see it says use technique, so because our person one was smaller than the other one, we
advise him to use his best techniques instead of trying to apply real force when fighting one on one,
because we one hell of a coach and want only the best for our fighter.
But what will happen if they are both the same size, so let's say we have the situation where both
are actually the same size.
Is there any special advice that we can give our fighter, if you will, on this example?
It's rather weird to have such a situation, but let's just say we have this other.
Condition.
So what you can do is you can have an else, if so, there are three different types of checks.
So the IV check, then the elusive check, and then finally the else, which is not really a check,
but which is a code that will be executed as a default if none of the above are true.
So what does that even mean?
Well, let's say we have an elective in between here.
So let me show you.
So we have an else if again, with a condition.
So here I'm going to say that those two have the same height.
So equal.
Equal.
All right.
So we had this first condition here, which was person one greater than that, person two.
Then we had the second condition here, which was high person one is equal to person two when it comes
to his size.
And then we can execute some code if that condition is met in here.
So let's just say something like use your power technique one three three seven, something like that.
So the fighter has a power technique and it's very useful against people who are the same height as
he is.
So you should use that technique.
But then we have this else block which will be executed if none of the above are true.
So if neither this if statement or this condition here is true, nor this condition here is true, then
the else block will be executed.
So then the text use technique will be executed instead.
Now, the cool thing is you can have as many electives as you want, so we could go ahead and check
if the height of person one is greater than 150 and execute some code, then check if what what should
happen if the person is smaller than 140 or all kinds of combinations that we can think of, even though
we have to be careful that certain conditions don't overlap with each other, because if they overlap,
then one of them will be useless.
OK, so what we have here, if we execute this, let's say when the person's one more person, one in
person, two are both one 170, then it should display use your power technique one three three seven.
So that we are it says use your power technique one three three seven.
So let's say one.
The person two is smaller than the person one then it should say use.
Raw force.
So that we are using your force.
All right, and what you see here, so this whole if else, if stuff is a controlled flow and we're
using if statements here now, little challenge for you, please go ahead and create an if else, if
else, if else, block where the first check will be greater equal 21.
And if that's the case, then it should write something like or print something like.
You may drink in the US then or else if the H is greater equal than 18, then you may vote.
And if somebody is older than 16, you may drive.
And then finally, if none of the above is true, then it should print something like you were too young.
So try to use this kind of structure to print those different statements based on a variable called
age that you, of course, also need to create.
So go ahead and try that.
All right, so I hope you pass the video, so I'm going to create this variable called H and actually
I'm not going to change it so I could go ahead and use a Veldheer.
So the variable will be H and then I use an if statement here.
If H was greater equal 21.
Then I want to print something saying now you may drink in the US because in other countries you may
drink before that, right?
If you do that, then in our case, of course, this will not be printed because age is not greater
than 21.
Let's have another check.
So else if the age is greater, equal 18.
So what should be printed if that's the case?
Well, let's print something like you may vote now.
All right, Prindle, and you may vote now and then we have another check age greater equal 16 and then
in the US you may drive.
So.
Prindle And you may drive now.
Of course, you need a license for that, but at least you can make the license or do the license at
this point and then you can use it.
And then finally we have an ELT's block which will be executed if none of the above is true, which
means if the person is.
15 or younger, then it should say something like.
You're too young to do whatever.
All right, so if we run this, you probably already guessed it, it will print.
You may drive now because our age is 17.
All right, so let's run this and there we are.
So it says you may drive now.
Now, if the age is that's a 31 as I am.
You can see it says now you may drink in the US.
All right, so, of course, I can do all of the others information as well, so I also may vote, I
also may drive now and so forth.
Of course, I could adjust the print statements here accordingly.
But this is the latest thing, so to speak, that I can do due to my age.
All right.
So we have this if else if else block that we can use in order to execute stuff when certain conditions
are met.
Now, by the way, a thing that you can also do if you have a very basic if statement.
So let's say you only have one line of code that follows a condition.
So H is creature equal 30.
Then you can just go ahead and do or add the text in the next one, you're over 30.
All right, so that's something that you can, of course, also do directly.
So just one line of code without having these extra curly brackets around it.
So if you see anything like that, that's what it does.
But you have to be careful because in the next line.
So if I add something like this in the next line.
This line will not be part of this if statement, so it will be executed either way.
So be careful here.
All right, so these are the statements, and in the next video, we're going to look at one because
you might see already that it's complaining.
So it says Kaskade IV should be replaced with one.
So let's do that in the next video.
So see you there.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.