1
00:00:00,000 --> 00:00:05,990
Boolean values in Python are the special True and False objects.

2
00:00:06,000 --> 00:00:12,990
So if I say 5 == 5, I get the True value back.

3
00:00:13,000 --> 00:00:17,990
And if I say 7 < 5, I get the False value back.

4
00:00:18,000 --> 00:00:23,990
So True and False are special values. They're actually of a Boolean class.

5
00:00:24,000 --> 00:00:27,990
If I say, type(True) <class 'bool'>.

6
00:00:28,000 --> 00:00:32,990
And we have a couple of operators for dealing especially with Boolean values.

7
00:00:33,000 --> 00:00:37,990
So if I say True and False, like that, I get False.

8
00:00:38,000 --> 00:00:41,990
If I say True and True, I get True.

9
00:00:42,000 --> 00:00:45,990
If I say True or False, that's True.

10
00:00:46,000 --> 00:00:50,990
If I say False or False, that's False.

11
00:00:51,000 --> 00:00:56,990
So the and, and the or operators, the ones that are spelled out as words, are

12
00:00:57,000 --> 00:00:59,990
especially Boolean operators.

13
00:01:00,000 --> 00:01:03,990
These are different then the bitwise, and, or.

14
00:01:04,000 --> 00:01:10,990
So if I say True & True, like this, I get True.

15
00:01:11,000 --> 00:01:13,990
The difference is that's a bitwise operator.

16
00:01:14,000 --> 00:01:20,990
I'm doing bitwise arithmetic, as opposed to simply Boolean arithmetic.

17
00:01:21,000 --> 00:01:24,990
I'm doing bitwise arithmetic, which is different then the Boolean operators.

18
00:01:25,000 --> 00:01:29,990
So the Boolean operators are and and or spelled out.

19
00:01:30,000 --> 00:01:31,990
And they're useful for things like this. If I have,

20
00:01:32,000 --> 00:01:41,990
say, two values a, b and they're 0, 1, and if I have another two values x, y and

21
00:01:42,000 --> 00:01:44,990
they're spelled out say 'zero', 'one',

22
00:01:45,000 --> 00:01:51,990
and I say x < y, which of course is False,

23
00:01:52,000 --> 00:01:54,990
and a < b, which of course is True,

24
00:01:55,000 --> 00:02:04,990
so I could say, if I wanted to, if a < b and x < y, of course, that won't be

25
00:02:05,000 --> 00:02:09,990
True print('yes') else:

26
00:02:10,000 --> 00:02:16,990
print('no') and it prints no.

27
00:02:17,000 --> 00:02:22,990
And so here I'm combining these two Boolean values. a < b, will result in a

28
00:02:23,000 --> 00:02:28,990
Boolean value of True. x < y results in a Boolean value of False.

29
00:02:29,000 --> 00:02:32,990
And so if they're both True, which they're not, we would print('yes').

30
00:02:33,000 --> 00:02:35,990
And if they're not both True then we'll print('no').

31
00:02:36,000 --> 00:02:38,990
So this is where you use the Boolean operators.

32
00:02:39,000 --> 00:02:41,990
You use them when you're operating on two Boolean values.

33
00:02:42,000 --> 00:02:46,990
And you're get these Boolean values typically in a comparison operation, like

34
00:02:47,000 --> 00:02:51,990
less than, or greater than, or one of the comparison operators that we covered in

35
00:02:52,000 --> 00:02:53,990
our movie on comparison operators.

36
00:02:54,000 --> 00:03:04,000
So that's the use of the Boolean operators, as opposed to the bitwise operators.

