1 00:00:00,000 --> 00:00:04,000 Let's come back a moment to the boolean data type. 2 00:00:04,001 --> 00:00:08,000 In this lesson, I'm going to show you how you can 3 00:00:08,001 --> 00:00:10,000 make some tests and get a boolean as a result. 4 00:00:10,001 --> 00:00:14,000 And this boolean will be the foundation for using conditions and loops. 5 00:00:14,001 --> 00:00:18,000 And for this lesson, I'm going to just use the 6 00:00:18,001 --> 00:00:20,000 Python shell here to keep things very simple. 7 00:00:20,001 --> 00:00:26,000 So first, we have the boolean data type with true and false as a value. 8 00:00:26,001 --> 00:00:28,000 Okay, only two values. 9 00:00:28,001 --> 00:00:33,000 Then what I can do, let's say I want to test the equality between two values. 10 00:00:33,001 --> 00:00:36,000 I want to test, so let's make a very simple test. 11 00:00:36,001 --> 00:00:39,000 I want to test if one is equal to one. 12 00:00:39,001 --> 00:00:40,000 And this is true. 13 00:00:40,001 --> 00:00:45,000 And as you can see, to test the equality, I use two equal signs, okay? 14 00:00:45,001 --> 00:00:51,000 Just one equal sign is to assign a value on the right to a variable on the left. 15 00:00:51,001 --> 00:00:54,000 With two equal signs, this is important to make the difference, 16 00:00:54,001 --> 00:00:58,000 this is going to compare the value on the left 17 00:00:58,001 --> 00:01:00,000 and the value on the right and return a boolean. 18 00:01:00,001 --> 00:01:03,000 Is this true or is this false? 19 00:01:03,001 --> 00:01:09,000 Now, if I want to test, let's say one is equal to two, well, this is false. 20 00:01:09,001 --> 00:01:12,000 Okay, so that kind of conditional statements, 21 00:01:12,001 --> 00:01:15,000 we are going to use that in the conditions and in the loops. 22 00:01:15,001 --> 00:01:18,000 Now, let's see what we can do here. 23 00:01:18,001 --> 00:01:20,000 So we can use integers, okay? 24 00:01:20,001 --> 00:01:22,000 We can compare two integers. 25 00:01:22,001 --> 00:01:27,000 We can also compare, let's see, two is equal to two. 26 00:01:27,001 --> 00:01:29,000 So 2.0 is equal to 2.0. 27 00:01:29,001 --> 00:01:31,000 We can also compare float number. 28 00:01:31,001 --> 00:01:36,000 We can compare strings. 29 00:01:36,001 --> 00:01:38,000 Okay, hello is equal to hello. 30 00:01:38,001 --> 00:01:43,000 Now, if I do the same, but let's say I put an uppercase here, this is false. 31 00:01:43,001 --> 00:01:47,000 And then, well, we have just seen the equal equal operator, okay? 32 00:01:47,001 --> 00:01:50,000 This is just one comparison operator. 33 00:01:50,001 --> 00:01:54,000 And you have different operators for different stuff you want to test. 34 00:01:54,001 --> 00:01:59,000 Now, let's say I want to test not the equality, but the inequality. 35 00:01:59,001 --> 00:02:02,000 I want to test if one is different than two. 36 00:02:02,001 --> 00:02:06,000 In this case, I'm going to use exclamation Mark equal. 37 00:02:06,001 --> 00:02:09,000 And this is true because one is different than two. 38 00:02:09,001 --> 00:02:14,000 If I test if one is different than one, this is false. 39 00:02:14,001 --> 00:02:16,000 Okay, so that's it for the equality. 40 00:02:16,001 --> 00:02:18,925 And now what you can test is you can test if a 41 00:02:18,937 --> 00:02:22,000 value is, for example, lower than another value. 42 00:02:22,001 --> 00:02:27,000 Let's test if one is lower than two with this angle bracket here. 43 00:02:27,001 --> 00:02:28,000 And this is true. 44 00:02:28,001 --> 00:02:31,000 Now, let's test if one is lower than one. 45 00:02:31,001 --> 00:02:35,082 This is false because just one angle bracket 46 00:02:35,094 --> 00:02:39,000 means that it is strictly lower than this. 47 00:02:39,001 --> 00:02:43,000 Okay, so one is not strictly lower than one. 48 00:02:43,001 --> 00:02:44,000 So this is false. 49 00:02:44,001 --> 00:02:48,000 Now, I can also test with the angle bracket and equal. 50 00:02:48,001 --> 00:02:53,000 And this means lower or equal than one. 51 00:02:53,001 --> 00:02:59,000 So if I press enter, we have true because one is lower or equal than one. 52 00:02:59,001 --> 00:03:01,000 And I can make the opposite or so. 53 00:03:01,001 --> 00:03:04,000 I can test if it is greater. 54 00:03:04,001 --> 00:03:08,000 So if one is greater than two, this is false. 55 00:03:08,001 --> 00:03:11,000 One is greater or equal than two. 56 00:03:11,001 --> 00:03:12,000 So this is still false. 57 00:03:12,001 --> 00:03:18,000 Let's put one and this is true because one is greater or equal than one. 58 00:03:18,001 --> 00:03:21,000 Okay, now two is greater than one. 59 00:03:21,001 --> 00:03:23,000 In this case, that works. 60 00:03:23,001 --> 00:03:27,000 Okay, so basically you have six comparison operators. 61 00:03:27,001 --> 00:03:32,308 The equal equal, the difference than, and then the strictly 62 00:03:32,320 --> 00:03:38,000 lower, lower or equal, strictly greater, and greater are equal. 63 00:03:38,001 --> 00:03:39,000 Okay. 64 00:03:39,001 --> 00:03:41,430 And just one last thing I'm going to show you which is very 65 00:03:41,442 --> 00:03:45,000 specific to Python is let's say you have a list, number list. 66 00:03:45,001 --> 00:03:51,000 I'm going to create a list with just some numbers. 67 00:03:51,001 --> 00:03:53,000 Okay, one, two, and four. 68 00:03:53,001 --> 00:03:59,000 What I can do is I can check if a value is inside that list very simply. 69 00:03:59,001 --> 00:04:05,000 I can do, for example, two in number list. 70 00:04:05,001 --> 00:04:06,000 And this is true. 71 00:04:06,001 --> 00:04:12,000 So you put first the value and then the keyword in and then the name of the list. 72 00:04:12,001 --> 00:04:15,000 So here we test if two is inside that list. 73 00:04:15,001 --> 00:04:17,000 Yes, because it's here. 74 00:04:17,001 --> 00:04:21,449 If I try with three in number list, this is false because 75 00:04:21,461 --> 00:04:26,000 there is no element that corresponds to three in the list. 76 00:04:26,001 --> 00:04:29,102 So that is very specific to Python and that's something 77 00:04:29,114 --> 00:04:32,000 that you are going to use also a lot in the future.