1 00:00:00,000 --> 00:00:03,840 Let's come back a moment to the Boolean data type. 2 00:00:04,019 --> 00:00:06,510 In this lesson, I'm going to show you how you can 3 00:00:06,510 --> 00:00:10,440 make some tests and get a Boolean as a result. And 4 00:00:10,440 --> 00:00:12,570 this Boolean will be the foundation for using 5 00:00:12,570 --> 00:00:15,510 conditions and loops. And for this lesson, I'm 6 00:00:15,510 --> 00:00:18,480 going to just use the Python Shell here to keep 7 00:00:18,480 --> 00:00:21,960 things very simple. So first, we have the Boolean 8 00:00:21,960 --> 00:00:26,670 data type, with True and False as a value. Okay, 9 00:00:26,760 --> 00:00:29,580 only two values, then what I can do, let's say I 10 00:00:29,580 --> 00:00:32,790 want to test the equality between two values, I 11 00:00:32,790 --> 00:00:35,880 want to test so let's make a very simple test. I 12 00:00:35,880 --> 00:00:39,510 want to test if one is equal to one. And this is 13 00:00:39,510 --> 00:00:42,660 True. And as you can see to test the equality I use 14 00:00:42,780 --> 00:00:46,920 two equal signs, okay, just one equal sign is to 15 00:00:46,950 --> 00:00:50,100 assign a value on the right to a variable on the 16 00:00:50,100 --> 00:00:53,310 left. With two equal signs, this is important to 17 00:00:53,310 --> 00:00:55,710 make the difference, this is going to compare the 18 00:00:55,710 --> 00:00:58,650 value on the left and the value on the right and 19 00:00:58,680 --> 00:01:03,120 return a Boolean. Is this True, or is this False? 20 00:01:03,180 --> 00:01:06,150 Now if I want to test, let's say one is equal to 21 00:01:06,540 --> 00:01:10,170 two, well, this is False. Okay, so that kind of 22 00:01:10,230 --> 00:01:12,750 conditional statements, we are going to use that 23 00:01:12,840 --> 00:01:16,170 in the conditions and in the loops. Now let's see 24 00:01:16,170 --> 00:01:20,460 what we can do here. So we can use integers. Okay, 25 00:01:20,460 --> 00:01:23,400 we can compare two integers, we can also compare, 26 00:01:24,720 --> 00:01:28,320 let's see two is equal to two. So 2.0 is equal to 27 00:01:28,320 --> 00:01:31,860 2.0. We can also compare float numbers. We can 28 00:01:31,860 --> 00:01:37,500 compare strings. Okay, hello is equal to hello. 29 00:01:37,770 --> 00:01:40,080 Now if I do the same, but let's say I put an 30 00:01:40,140 --> 00:01:43,980 uppercase here, this is False, and then well, we 31 00:01:43,980 --> 00:01:46,980 have just seen the equal equal operator. Okay, 32 00:01:46,980 --> 00:01:50,280 this is just one comparison operator, and you have 33 00:01:50,550 --> 00:01:53,580 different operators for different stuff you want 34 00:01:53,580 --> 00:01:56,430 to test. Now let's say want to test not to be 35 00:01:56,460 --> 00:02:00,570 equality, the inequality. I want to test if one 36 00:02:00,600 --> 00:02:03,450 is different than two. In this case, I'm going to 37 00:02:03,450 --> 00:02:07,260 use exclamation mark equal. And this is True 38 00:02:07,260 --> 00:02:10,680 because one is different than two. If I test if 39 00:02:10,710 --> 00:02:14,670 one is different than one, this is False. Okay, so 40 00:02:14,670 --> 00:02:17,250 that's it for the equality. And now what you can 41 00:02:17,250 --> 00:02:19,800 test is you can test if a value is for example, 42 00:02:19,800 --> 00:02:23,430 lower than another value. Let's test if one is 43 00:02:23,460 --> 00:02:26,880 lower than two with this angle bracket here. And 44 00:02:26,880 --> 00:02:30,480 this is True. Now let's test if one is lower than 45 00:02:30,480 --> 00:02:34,140 one, this is False, because just one angle bracket 46 00:02:34,170 --> 00:02:39,060 means that it is strictly lower than this, okay. 47 00:02:39,570 --> 00:02:43,350 So one is not strictly lower than one. So this is 48 00:02:43,350 --> 00:02:47,040 False. Now I can also test with the angle bracket 49 00:02:47,100 --> 00:02:52,200 and equal and this means lower or equal than one. 50 00:02:52,440 --> 00:02:56,700 So if I press Enter, we have True because one is 51 00:02:56,730 --> 00:03:00,210 lower or equal than one. And I can make the 52 00:03:00,270 --> 00:03:04,800 opposite also, I can test if it is greater. So if 53 00:03:04,800 --> 00:03:08,730 one is greater than two, this is False. One is 54 00:03:08,730 --> 00:03:12,360 greater or equal than two, so this is still False. 55 00:03:12,390 --> 00:03:15,570 Let's put one and this is True because one is 56 00:03:15,570 --> 00:03:19,530 greater or equal than one. Okay, now, two is 57 00:03:19,530 --> 00:03:23,640 greater than one. In this case, that works. Okay, 58 00:03:23,640 --> 00:03:27,077 so basically, you have six comparison operator, 59 00:03:27,077 --> 00:03:31,590 the equal equal, the difference, then, and 60 00:03:31,590 --> 00:03:35,190 then the strictly lower, lower or equal, strictly 61 00:03:35,190 --> 00:03:39,600 greater, and greater or equal. Okay. And just one 62 00:03:39,630 --> 00:03:41,580 last thing I'm going to show you, which is very 63 00:03:41,580 --> 00:03:44,220 specific to Python, is let's say you have a list, 64 00:03:44,250 --> 00:03:47,700 number_list. I'm going to create a list with just 65 00:03:49,410 --> 00:03:54,060 some numbers, okay, one, two, and four. What I can 66 00:03:54,060 --> 00:03:58,080 do is I can check if a value is inside that list, 67 00:03:58,110 --> 00:04:04,663 very simply. I can do for example, to in number_list, 68 00:04:04,663 --> 00:04:07,170 and this is True. So you put first the 69 00:04:07,170 --> 00:04:10,890 value, and then the keyword in and then the name 70 00:04:10,920 --> 00:04:14,820 of the list. So here we test if two is inside that 71 00:04:14,820 --> 00:04:18,089 list, yes, because it's here. If I try with three 72 00:04:18,630 --> 00:04:22,650 in number list, this is False because there is no 73 00:04:22,710 --> 00:04:26,400 element that correspond to three in the list. So 74 00:04:26,400 --> 00:04:28,680 that is very specific to Python. And that's 75 00:04:28,680 --> 00:04:32,600 something that you are going to use also a lot in the future.