Afrikaans
Akan
Albanian
Amharic
Arabic
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
Icelandic
Igbo
Indonesian
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
Hello and welcome back to another Alphatech Academy video.
My name is Vlad.
And in this video, we're going to talk about logical operators.
So we use the logical operators in our day to day life without paying much attention to it.
For example, if we can take a slice of bread and some spread, then we can make a delicious sandwich.
Another example, we can say that if it's raining outside or worry it's cold today, then you should
take your jacket with you.
So if we take a look at the first example, we can see that it has basically two, let's call it this
way, to sub conditions.
The first one is if we take a slice of bread.
This is the first condition.
And the second one is if we take some spread and if we want to use some formality here, there are these
two sub conditions are called operands.
So there is the first one and the second one.
And these two sub conditions.
These two operands, basically what they do is they form by using a logical and operator.
They form a new condition.
And this combined condition may also be true or false based on the status on the result of these SAB
condition, based on the result of these two operands.
And they're the and logical operator that we use between them.
And now the question that remains is how can we decide if the result will be true or false?
And for that, we can use a truth.
They will.
That will help us with the decision.
And this truth table is very straightforward.
Once you understand it.
So let's suppose that we have this little nice table with a couple of columns and a couple of rows.
And we will say that the first column will represent the status or the result of the first operand over
the first subcommission, which we took, for example, that it stands for.
If we take a slice of bread.
OK.
So that's the first operand.
And the second column in this truth table will represent the status of the second sub condition of the
second operand, which stands for.
If we take a spread.
So the first condition is if we take a bread, OK.
And the second one, if we take a spread and each of these operands may be either a true or false.
And basically there is a total of four optional combinations between them.
Either both of them are true or maybe one of them is true and the second one is false or both of them
are false.
Let's eat.
Right.
Either both of them are true or the first one is true.
The second one is false or otherwise.
The first one is false and the second one is true, or both of them are false.
There are no other combinations that you can do with these two sub conditions.
All right.
So these were just the operands of our overall expression.
Now, let's see what would be the result of using an and logical operator on both of them.
So if you have a slice of bread and you have a spread, then it means you can make a sandwich.
So it means that if both of these sub conditions are true, then the overall resolved is true.
You can make a sandwich.
But if you don't have at least one of them either, it's a slice of bread, worries bread.
Then you can not make a sandwich.
You will have just one of the ingredients.
But it will be it won't be sufficient to make your favorite sandwich.
Right.
So the overall result in this case is that both of them are going to be false.
And lastly, if there is no bread and no spread, then it is obvious that there is no sandwich.
So the result is definitely going to be false.
Now, what we've done is we've simply created a truth table for the for the and logical operator.
So whenever you're going to work with a and and logical operator and you have a couple of sub conditions,
you can use these Troost, they will to help you understand what will be the result, the overall result
of the condition itself.
So once again, based on the status of the given operands that you can see in these columns, if you
use the logical and operator between the two, then the result is going to be exactly as you can see
on the last column, on the right one.
So I hope that's clear to you guys.
And you understand everything we've just discussed.
And just to make sure that you do.
I'm going to give you another.
Example using the and logical operator.
So let's say that you want to ask for some money from I don't know whom maybe your parents, your friends,
your colleagues or anyone else.
And since you know they care for you, you know they will help you, but they will help you only if
you have less than, let's say, 50 bucks in your wallet.
And also, they will not just give you the money based on that condition alone.
They also want you to succeed in school.
So there is a second condition which says that you have to get a grade higher than 90 on your programming
the exam.
And if both of these conditions are satisfied, then you will preened the following message.
Give me some money, please.
I've earned it with a high grade and nothing in my pocket.
So pretty funny example.
But let's try to look more into it.
So this message will be printed only if both of these conditions happen to be true.
So we've won.
We have less than 50 bucks in a wallet.
And two, if we've got a grade higher than 90 on our last exam, only then we would preened this message,
asking for some money in a reward.
So I hope the example is clear to you guys and you understand the logic behind using IM and logical
operator.
And now what I want to do is to talk about the second example, a sentence we probably mentioned at
the beginning of the topic, I guess.
And it goes like this if it's raining outside or it's cold today.
Take your jacket with you.
Let's try to construct to the or a logical operator a table ourselves, shall we?
So first of all, we can say that the first operand, the first sub condition relates to if it's raining
outside and the second one relates to if it's cold today.
And if both of them are true, we can say that we definitely should take the jacket.
Right.
If both of them are true, if it's called and if it's raining, then we should take our A jacket with
us.
We know that if it's raining outside, then it doesn't matter if it's called or not, then we should
also take a jacket with us.
Similarly, we if we know that it's cold outside, then it doesn't matter if it's raining because it's
cold, it's outside.
So meaning that for both of these cases, if one condition, at least one condition happens to be true,
the result is also going to be true.
So we need the jacket with us.
And lastly, only if it's not raining and it's not cold today, only then you don't have to take your
jacket with you.
Meaning the result in this case will be false.
It's not cold.
There is no rain and there is no reason to take the jacket with us.
So that's basically how you create a truth.
They will for the or logical operator and just go over it once again.
If either of the conditions, either of the operands happened to be true, then the overall result will
be true.
And just remember this nice example of the called Arean.
If it's raining example that we use right now and shoot you or shoot, should you not take your jacket
with you?
And that's good guy sound.
Now we know how the logical or operator and the logical and operator, how both of them work.
And now we can simply summarize what we've learned so far.
So we may have a couple of operands, a couple of these sub conditions.
And also we may have some logical operators that are applied on these operands.
And the final result of all of these, let's say, process is decided to be either true or false.
It doesn't matter if it's complicated and it doesn't matter how much operands or logical operators you
may use.
The final result may only be either a true or false.
It also it all comes to these same programming.
OK, eventually that's all we have.
Either a true or false sense, zero or one.
And that's how programming work.
So I hope this structure, their usage of these truth tables is clear to you guys.
And one last thing that I want to talk about in these video is the last logical operator, which is
called the not logical operator.
And the it's the easiest one, actually.
It simply takes some expression and whatever its final result to you, the way it's true or false.
These not.
Rader will return the inverse value.
So we feel is applied on a value that happened to be true.
Then the final result would be false.
And vice versa.
So we'd simply negates the result.
And once again, if this not operator is applied on some expression, which is true, then the final
result is going to be false.
And if it is applied on an expression which happens to be false, then the final result is going to
be true.
So thank you guys for watching your on Alphatech Academy programming course.
My name is Vlad.
And now we can move on to practice logical operators in our programming language.
I'll see you there.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.