Let's come back a moment to the boolean data type.
In this lesson, I'm going to show you how you can
make some tests and get a boolean as a result.
And this boolean will be the foundation for using conditions and loops.
And for this lesson, I'm going to just use the
Python shell here to keep things very simple.
So first, we have the boolean data type with true and false as a value.
Okay, only two values.
Then what I can do, let's say I want to test the equality between two values.
I want to test, so let's make a very simple test.
I want to test if one is equal to one.
And this is true.
And as you can see, to test the equality, I use two equal signs, okay?
Just one equal sign is to assign a value on the right to a variable on the left.
With two equal signs, this is important to make the difference,
this is going to compare the value on the left
and the value on the right and return a boolean.
Is this true or is this false?
Now, if I want to test, let's say one is equal to two, well, this is false.
Okay, so that kind of conditional statements,
we are going to use that in the conditions and in the loops.
Now, let's see what we can do here.
So we can use integers, okay?
We can compare two integers.
We can also compare, let's see, two is equal to two.
So 2.0 is equal to 2.0.
We can also compare float number.
We can compare strings.
Okay, hello is equal to hello.
Now, if I do the same, but let's say I put an uppercase here, this is false.
And then, well, we have just seen the equal equal operator, okay?
This is just one comparison operator.
And you have different operators for different stuff you want to test.
Now, let's say I want to test not the equality, but the inequality.
I want to test if one is different than two.
In this case, I'm going to use exclamation Mark equal.
And this is true because one is different than two.
If I test if one is different than one, this is false.
Okay, so that's it for the equality.
And now what you can test is you can test if a
value is, for example, lower than another value.
Let's test if one is lower than two with this angle bracket here.
And this is true.
Now, let's test if one is lower than one.
This is false because just one angle bracket
means that it is strictly lower than this.
Okay, so one is not strictly lower than one.
So this is false.
Now, I can also test with the angle bracket and equal.
And this means lower or equal than one.
So if I press enter, we have true because one is lower or equal than one.
And I can make the opposite or so.
I can test if it is greater.
So if one is greater than two, this is false.
One is greater or equal than two.
So this is still false.
Let's put one and this is true because one is greater or equal than one.
Okay, now two is greater than one.
In this case, that works.
Okay, so basically you have six comparison operators.
The equal equal, the difference than, and then the strictly
lower, lower or equal, strictly greater, and greater are equal.
Okay.
And just one last thing I'm going to show you which is very
specific to Python is let's say you have a list, number list.
I'm going to create a list with just some numbers.
Okay, one, two, and four.
What I can do is I can check if a value is inside that list very simply.
I can do, for example, two in number list.
And this is true.
So you put first the value and then the keyword in and then the name of the list.
So here we test if two is inside that list.
Yes, because it's here.
If I try with three in number list, this is false because
there is no element that corresponds to three in the list.
So that is very specific to Python and that's something
that you are going to use also a lot in the future.