00:00So far we've learned about rational operators and equality operators, and the last operators we want to talk about in this round is logical operators.
00:13Logical operators enable us to compare more than one thing.
00:17So as if we do a really quick recap about rational operators, let's create here a Boolean value is test.
00:28OK, I'm just going to call it isTest, which will be a Boolean value.
00:31Let's give it an initial value of true, which you could just hard-coded and really set it to true.
00:37Now let's try to set a value into isTest that would be a rational operator.
00:42Let's check if 3 is greater than isTest, which is a valid statement.
00:51Is 3 greater than 1? Yep, 3 is greater than 1 because isTest is converted into 1.
00:58So is 3 greater than isTest? Let's check how much isTest equal now.
01:04Is isTest still true? And it is. Very good.
01:11Let's move on. You could leave it in the same row.
01:18Let's move on. So we've done a rational operator, operators greater, smaller, equals.
01:25The next set we tested were equality operators, such as isTest equals 1, equals, equals, equals isTest.
01:40And that should come back as false because isTest is not explicitly equal to 1.
01:45Although it is equal to 1, it's not explicitly equal to 1.
01:49So if we test our isTest now, it should come back as false.
01:54But if we wanted to stay as true, we could, instead of that, ask it if it's not explicitly equal to 1.
02:01And 1 is not explicitly equal to 1. So our trace should come back as true.
02:07Okay, so we're still at true. Let's just type it here just for reference.
02:15So we've talked about rationals. We've talked about equality.
02:21Let's look at logical. Logical enables us to compare more than one item.
02:27So for example, isTest, let's create a few variables for us to test.
02:33We're going to create a variable called a, which will be a number, not a null, a number.
02:40And we'll give that value of 10.
02:45And we'll create another variable, which we're going to call b, which will be a number as well.
02:49And we'll give it the value of 20. And we'll create one last number.
02:56And we're going to give it a value of 30. And now because we're working only with rational numbers,
03:02there's no real reason for us to use numbers. Let's leverage some of the knowledge that we had from the last videos.
03:08And let's use UN because we're only going to work with positive integers.
03:14So I'm going to change that to be UN. It's going to be better for the processor.
03:18It's going to make things run more smoothly.
03:22Let's delete this part because we're not really there.
03:26Let's look at our isTest again.
03:30So we've seen that we could compare between, let's say, a is a greater than b.
03:38Or let's put there something that actually would be true as b greater than a.
03:43And we've seen how to do that. And that would come back as true.
03:47What if we wanted to compare if b is greater than a and that b is smaller than c?
03:55The way we would do that, we would use the end-end operator,
04:00which will basically mean that we want to compare this value and that value.
04:06And only if both values come back as true, then return true to our trace, to our isTest in this scenario.
04:13So let's continue. So if b is greater than a and end,
04:20if b is smaller than c, then return a value of true to isTest.
04:28So if we trace out this value, we should still be getting true.
04:34And indeed, we're getting still true.
04:39Let's put here an equation that's not true.
04:45Put here an equation that sounds quite easy to do that.
04:48Let's type it for practice.
04:51If b is smaller than a and end, b equals equals 20.
05:00This is true, but it's never even going to get here because this is false.
05:04And because this is false, as soon as we trace out, because b is not smaller than a,
05:09b is larger than a, isTest would come back as false.
05:18Or in other words, what we're basically tracing right here,
05:21if I'll just directly go for a trace, I'm basically tracing isFalse and endTrue,
05:31which is the exact same thing as this expression.
05:35Or is that Boolean?
05:37And isFalse and endTrue?
05:40No, because only if it's true on both sides, then it would return as true.
05:44So this trace should return false.
05:46Very good.
05:49Okay, so we're starting to get a hang on how to work this logical operator.
05:55What if we wanted to check or?
05:58Which basically means we want to check if this side is true or the other side is true.
06:05How would we do that?
06:07Okay, let's see how we would do that.
06:09For example, isTest equals, let's check if C equals, explicitly equals 30.
06:18Or C equals 20.
06:24Now let's trace that one out.
06:28So notice that the way, oh, I've added here one, two, and many brackets.
06:36Notice that this is the sign that I'm using.
06:38I'm using two pipes.
06:40I'm using two pipes to say or, not one, two.
06:44Same thing for the end.
06:46You always type two.
06:48Okay, so what would the value that would come back here?
06:52So one, is C explicitly equal to 30?
06:55Yep, definitely.
06:5630 equals 30 no matter how you try and wrap it around.
07:0120, is C equal 20?
07:02No, so 20, that would be not true, but it doesn't really matter because it's an or.
07:06So because it's true on this end, the isTest is going to return as true.
07:11So if you run the application, isTest will come back as true.
07:15Now, just as a side note, this equation would never even compute because FlashReady would see that this is true
07:22and it would see that there's an or statement here, so this wouldn't even ever execute.
07:28It's kind of irrelevant as soon as this became true.
07:31Well, if the value here would be not true, okay, we could make it not true right here just by making it not.
07:40So is C not explicitly 30?
07:42It absolutely is explicitly 30, thus this is false, and this is false as well.
07:49So the value that would come back would be false because there is no true.
07:55What would happen if we would take the exact same value, let me just grab this, copy this,
08:03and change the or to be end.
08:08What value do you think would come back?
08:10I'm going to keep quiet for a second here so you could think about it.
08:14And the value is false again.
08:21Let's try to analyze it and figure out why is it false.
08:24The value that's coming back here is false, and the value that's coming back here is false as well.
08:29So false and false together are still false because we would expect true on both ends for it to be true.
08:36While in an or statement we will expect only one to be true, or at least one to be true.
08:42And it does not match in that case either.
08:45So let's try one more experiment here.
08:48Let's ask if C equals 30 and end B equals 20.
09:02And if we look back into our variables, if you forgot them, B equals 20 and C equals 30.
09:08So is this valid? Absolutely.
09:11Because C equals 30, that's true, and B equals 20, that's true as well.
09:15And because we're looking for an end, it's comparing both.
09:18And if we check our is test, which we'll output in our last is test, it should come back as true.
09:24Excellent.
09:26Now if we grab the same equation, and instead of that change that to be an or,
09:34and so we're asking if this is true or that is true, and we already know that both are true,
09:40then for it's either or, if one of them is true, that's it.
09:44Okay, it's true.
09:45Okay, so basically, well not only basically, the value that would come back would be true.