‫Welcome back.
‫And let's talk another term.
‫Logical operators.
‫And they're very, very useful when it comes to conditional logic.
‫Let's have a look.
‫Logical operators are.
‫Well, as a matter of fact, you've actually seen them before and is a logical operator.
‫Or is a logical operator, it allows us to perform logic between two things.
‫What else is a logical operator?
‫Well, let me list it out for you.
‫We have greater than.
‫Less than.
‫Equal to.
‫Let's actually use them in an example is for greater than five.
‫Well, if I print this.
‫What do you think will happen?
‫Shouldn't be a surprise.
‫That's false.
‫Four is not greater than five.
‫This is a logical operator that you may have seen in math class.
‫If I do, the opposite is for less than five.
‫That makes sense.
‫That's true.
‫What about is four equal to five?
‫If I run this, I get false.
‫Now, why did I use two equals here?
‫Why not just do this?
‫Well, if I run here.
‫I get an error syntax.
‫Error keyword can be an expression.
‫It's because, remember, equal is what we use to assign to a variable.
‫Right.
‫And if you remember, I told you that a variable in Python can start with a with a number.
‫It has to be a letter or underscore.
‫So when I do this, it's going to air because the interpreter is going to say, Hey, I'm trying to
‫assign variable for the value of five, and well, that's not really allowed.
‫So we use double equals to tell the interpreter, Hey, I'm not assigning a variable here.
‫I want to compare things and we can compare different things.
‫I can do.
‫Hello equals two.
‫Hello.
‫Equal to true.
‫What if I do A is greater than B?
‫I get false.
‫Now, why is that?
‫This.
‫I want you to Google on your own and figure out why is a greater than be.
‫What if I do?
‫A is that greater than capital?
‫A.
‫That's true.
‫Hmm.
‫This is this is interesting and this is actually quite an interesting reason.
‫So I know I know it's easy for me to just give you an answer, but I want you to practice Googling this.
‫And the reason I'm not giving you an answer is it's also because it's not very important, because most
‫of the time you want to make code that is easy to understand and understandable.
‫You're most likely using greater than less than with numbers.
‫So if you see something like this in code, well, you wouldn't know what's going on.
‫What is this person trying to compare?
‫Why are they doing?
‫Is lowercase a greater than capital?
‫A It's not something that you see very often, but the reason you get this expression is quite interesting.
‫So I do recommend you Google Google into it.
‫Like I said, I'm a strong believer in not holding your hand the entire way.
‫I know so far the videos up until now have been quite easy, especially if you are an experienced programmer.
‫But as we progress, you'll see that after this course you need to figure things out on your own.
‫And my job is not to just hand-hold you the entire way, it's to develop the skills in you to become
‫an employable programmer.
‫So I hope you bear with me as I just give you this little challenge.
‫All right.
‫We want a bit on a tangent, so let's bring it back.
‫Can I do things like this?
‫Is one greater than two?
‫Or you know what?
‫Let's do less than two and less than three and less than four.
‫Will this work?
‫Well, of course it will.
‫It's just an expression, right, that we're evaluating.
‫And all of this is true.
‫But as soon as I change.
‫And something is false.
‫It's going to short circuit which we learned about previously and return false.
‫All right.
‫So we know the greater than equal to less than sign.
‫We also have greater than or equal to.
‫So that if I do.
‫Zero here and I click Run.
‫I get true because it's saying, hey, is this greater than or equal to zero?
‫I can also do less than or equal to zero.
‫And here I get false because zero or one is not greater or equal to zero.
‫But if I do zero here, I'll get true.
‫Here's another one.
‫What if I do this?
‫Exclamation mark equal.
‫This means in Python, not equal to.
‫If I run this.
‫I get false.
‫And this is a little tricky.
‫What it's saying is, hey, is this not equal to this?
‫So it's the opposite of doing equals.
‫If these two things don't equal, it's going to say true.
‫So if I do one.
‫Here, I'll get true because these two things do not equal.
‫So we've learned greater to or less than greater to equals equals or greater or greater or equal to.
‫We've learned about less than or equal to.
‫We've learned about.
‫Not equal to.
‫But we've also learned about.
‫End and or.
‫And finally, there's one more I want to teach you.
‫And it's the not.
‫Keyword.
‫I know.
‫It's.
‫It's a little.
‫It's a little much, but it's not as hard as you think.
‫Not is.
‫Well, the opposite.
‫So if I do hear.
‫Not.
‫True.
‫What do I get?
‫I get false and you see that not as also a function.
‫So it's a keyword, but also a function that we can use.
‫If I do not false.
‫Again.
‫I just get the opposite.
‫What if I do this?
‫What if I do not want?
‫Equals to one?
‫Well.
‫Will I get here?
‫I get false because this expression evaluates to true and then not just does the opposite.
‫So let's take a break here and work on a little bit of an exercise to make sure that we understand this.