1 00:00:00,120 --> 00:00:02,400 Hello In this tutorial. 2 00:00:02,400 --> 00:00:11,670 We are going to discuss about the bullying data type Python uses boolean variables in order to evaluate 3 00:00:12,180 --> 00:00:16,280 conditions consider this statement. 4 00:00:16,320 --> 00:00:16,950 7. 5 00:00:16,990 --> 00:00:21,090 Greater than 3 because 7 is greater than 3. 6 00:00:21,130 --> 00:00:28,640 Python would return true since 10 is less than or equal to 20. 7 00:00:28,690 --> 00:00:37,520 In this case is when the Boolean value true is not done next. 8 00:00:37,640 --> 00:00:41,620 This is the not equal to operator. 9 00:00:41,720 --> 00:00:43,130 So by then checks. 10 00:00:43,190 --> 00:00:48,470 If these string on the left is same as a string then the right. 11 00:00:48,530 --> 00:00:53,330 Since this is not true the output would be once 12 00:00:56,080 --> 00:00:57,220 next. 13 00:00:57,520 --> 00:01:01,310 The double equal to operator. 14 00:01:01,540 --> 00:01:09,090 We know that that the single equal to operator is used for variable assignment. 15 00:01:09,190 --> 00:01:17,110 If we use a double equal to operate it means the number on the left is compared to the number on the 16 00:01:17,110 --> 00:01:17,720 date. 17 00:01:17,790 --> 00:01:26,230 It checks if both these numbers are the same or not since 5 is not equal to 6. 18 00:01:26,240 --> 00:01:32,990 This would do it on flight in Python. 19 00:01:32,990 --> 00:01:45,620 That at 6 comparison operators which all produce a boolean deserve the boolean values false and true 20 00:01:46,020 --> 00:01:49,190 are the only boolean objects. 21 00:01:49,190 --> 00:02:01,110 These objects behave like the values 0 and 1 respective mixed bool method. 22 00:02:01,180 --> 00:02:09,510 The ball method converts a value to boolean using the standard road testing procedure. 23 00:02:09,880 --> 00:02:14,190 And this is the syntax for the bool mentor. 24 00:02:14,380 --> 00:02:27,240 So if we pass this statement 7 greater than 3 to the bool method Python should return the Boolean value 25 00:02:27,390 --> 00:02:40,420 true similarly if we pass this statement to the ball method Python returned the Boolean value true. 26 00:02:40,780 --> 00:02:49,840 So let's test this in our Jupiter notebook so here in this line in the cell I have two strings. 27 00:02:49,840 --> 00:03:00,040 Cats and dogs and I want to compare both of the strings and then return Boolean value true or false. 28 00:03:00,040 --> 00:03:06,070 So I have parse this expression to the ball method and then let execute. 29 00:03:06,160 --> 00:03:15,390 This returns true because the expression on the left is not equal to the expression on the right. 30 00:03:15,760 --> 00:03:21,490 Next let us say Let us compare the two numbers. 31 00:03:21,610 --> 00:03:24,990 10 equal to equal to 20. 32 00:03:25,420 --> 00:03:32,830 So as we have discussed before these single equal to operate word is used for assignment whereas the 33 00:03:33,010 --> 00:03:39,790 double equal to operator is used to compare variables or expressions. 34 00:03:40,000 --> 00:03:42,840 So let's execute this line of code. 35 00:03:43,870 --> 00:03:49,250 So this returns false because 10 is not equal to 20. 36 00:03:49,330 --> 00:03:58,330 It is not mandatory to pass a value to the bool metal if you do not pass a value. 37 00:03:58,500 --> 00:04:01,950 The bool method returned false 38 00:04:05,340 --> 00:04:09,350 in general use ball takes a single parameter value. 39 00:04:09,840 --> 00:04:21,490 So let's test this in the Jupiter note book so let's not fives a new value to be bool mentor then execute 40 00:04:21,520 --> 00:04:25,070 this line so it return defaults. 41 00:04:28,320 --> 00:04:35,550 So if you do not pass any value to the bool method it returns the Boolean value false. 42 00:04:35,850 --> 00:04:47,070 Similarly if you pass falls to the bool method it returns a false and also the Integer 0 or the floating 43 00:04:47,070 --> 00:04:51,350 point number zero point zero the output would be acquired. 44 00:04:51,360 --> 00:04:59,250 Similarly if you pass an empty string on an empty list or and or add an empty tuple the output would 45 00:04:59,250 --> 00:05:00,750 be false. 46 00:05:00,840 --> 00:05:13,480 Also if you pass an empty dictionary the output is quite so let pass the Boolean value falls to the 47 00:05:13,480 --> 00:05:18,420 method bool so it is returning applies. 48 00:05:18,520 --> 00:05:20,330 Let us pause. 49 00:05:20,710 --> 00:05:30,140 0 0 in best motorboat the floating point numbered 0 0 0 50 00:05:33,060 --> 00:05:34,380 let us change this. 51 00:05:34,380 --> 00:05:43,110 Number two to two point or and then execute it or done to grow similarly if you pass an empty string 52 00:05:43,740 --> 00:05:52,780 so I'm sure I'm not going to endure anything in between the deem limited single quote so it does you're 53 00:05:52,780 --> 00:06:04,210 turning the quote Let us pass an empty list a list is denoted with the square brackets. 54 00:06:04,530 --> 00:06:12,790 So it is returning a points so this is about the bold matured. 55 00:06:12,840 --> 00:06:14,940 Consider this expression. 56 00:06:14,940 --> 00:06:28,050 We know Python returned the Boolean value true when it evaluates the statement so I can also assign 57 00:06:28,710 --> 00:06:32,290 this expression to a variable. 58 00:06:32,500 --> 00:06:41,680 And now when I rent this variable X the result would be true. 59 00:06:41,710 --> 00:06:45,780 We can assign a boolean expression to a variable. 60 00:06:46,000 --> 00:06:54,470 Say for example X is equal to see a greater than nine. 61 00:06:55,130 --> 00:07:02,590 So in this case the output of this boolean expression assigned to the variable x. 62 00:07:02,690 --> 00:07:11,820 So let's go execute this line of code and then print the variable X in order to check the output and 63 00:07:11,820 --> 00:07:14,790 then print x. 64 00:07:14,970 --> 00:07:22,500 So it does returning a file so we can assign boolean expressions to a variable like this. 65 00:07:22,500 --> 00:07:30,290 Also you can print the result of boolean expressions using the print function. 66 00:07:30,300 --> 00:07:41,990 Say for example you want to test it for 30 is equal to hard to say for example you want to compare these 67 00:07:41,990 --> 00:07:48,110 to the number thirty with the number 30 using the double equal to sign. 68 00:07:48,110 --> 00:07:59,070 So after you execute this the print function returned the output of the boolean expression let us consider 69 00:07:59,100 --> 00:08:00,000 this example. 70 00:08:00,000 --> 00:08:10,680 We have 3 the worlds in which A is assigned to 10 B is assigned to 7 and c is assigned to 6 and we have 71 00:08:10,680 --> 00:08:19,020 2 expressions used here we are using the comparison operators to compare the variables in B and the 72 00:08:19,020 --> 00:08:30,270 greater than or equal to operator to compare the variables A and C since we have two conditions to evaluate. 73 00:08:30,270 --> 00:08:47,060 We can use the the fight in logical operators and or and non to combine more than one condition C for 74 00:08:47,060 --> 00:08:51,590 example I want to check if both of these expressions are TRUE OR NOT 75 00:08:54,750 --> 00:09:03,170 I CAN USE THE and operating in this expression. 76 00:09:03,360 --> 00:09:10,280 The first expression used is true because 10 is greater than or equal to 7. 77 00:09:10,410 --> 00:09:23,090 The second expression is also true so finally Python would return the Boolean and do true so if the 78 00:09:23,180 --> 00:09:30,670 board the conditions are true then the expression as a whole returned the Boolean value true. 79 00:09:30,770 --> 00:09:40,950 The logical operators in Python combine two or more conditions and perform logical operations D and 80 00:09:40,980 --> 00:09:42,300 operate. 81 00:09:42,420 --> 00:09:54,840 Returns true if both the opposite ends at true coming to the odd operator the odd operator returns true 82 00:09:55,230 --> 00:09:59,080 if e did of the opposite end. 83 00:10:00,290 --> 00:10:00,710 Is true 84 00:10:03,500 --> 00:10:05,330 the not operated 85 00:10:08,030 --> 00:10:17,330 if a particular condition is true the not operated that don't fault means it complement the operation 86 00:10:19,890 --> 00:10:22,490 in this cell. 87 00:10:22,580 --> 00:10:29,150 We are comparing the the number 10 with the number 10 using the double equal to operator. 88 00:10:29,160 --> 00:10:39,130 Then if we print this line of code it returns true if we use the not operator before this expression 89 00:10:39,130 --> 00:10:43,770 and then execute it invert the doors. 90 00:10:44,080 --> 00:10:48,550 Next is the membership by an operator. 91 00:10:48,550 --> 00:10:57,500 These operators to test whether their value is a member of a sequence and this sequence could be a list 92 00:10:57,670 --> 00:11:06,430 of a string tuple and we have two Python membership operators in and not in 93 00:11:09,240 --> 00:11:21,000 so I want to check whether the character T is a substring or the string python and then evaluate this 94 00:11:21,000 --> 00:11:21,600 too. 95 00:11:22,660 --> 00:11:32,780 So this is true since this character T is present in Python and this chick and not the example. 96 00:11:33,900 --> 00:11:45,450 Let us check if this particular substring is present in python in the string python and then execute. 97 00:11:45,900 --> 00:11:55,470 So since Python could not find t or end in the string Python it has returned a false letter saying we 98 00:11:55,470 --> 00:12:02,930 will now use the membership operator not in and then execute. 99 00:12:03,490 --> 00:12:10,430 So in this case it would return true next is identity operators. 100 00:12:10,430 --> 00:12:18,100 We have two identity operators is is nine is evaluates to true. 101 00:12:18,230 --> 00:12:26,750 If the variable than either side of the operator point to the same object and false otherwise is not 102 00:12:26,810 --> 00:12:28,710 evaluated two fold. 103 00:12:28,790 --> 00:12:35,990 If the variables on either side of the operator bind to the same objects and true otherwise. 104 00:12:36,090 --> 00:12:42,660 So let's understand the identity operators is and is not using an example. 105 00:12:44,070 --> 00:12:52,360 Identity operators using a simple example here we have two variables A and B they are pointing to the 106 00:12:52,360 --> 00:12:59,190 same memory location containing the value 10 and there is another variable C that is pointing to a memory 107 00:12:59,190 --> 00:13:07,540 location containing the value 15 so a and b a it. 108 00:13:07,540 --> 00:13:12,360 And when we use the identity operator A is B. 109 00:13:12,430 --> 00:13:21,810 This should return true because are pointing to the same memory location same value and a C. 110 00:13:21,970 --> 00:13:28,450 This should return false because they are pointing to different values. 111 00:13:28,810 --> 00:13:31,670 So what would this expression red done. 112 00:13:31,680 --> 00:13:41,830 B is not C and this is true let us check this in the Jupiter note book. 113 00:13:41,980 --> 00:13:46,170 So I have defined the variables A B and C. 114 00:13:46,200 --> 00:13:48,750 Now let us test the identity. 115 00:13:48,760 --> 00:13:54,920 Operator e is B. 116 00:13:55,140 --> 00:14:02,010 So this is true because a and b are binding to the same object. 117 00:14:03,060 --> 00:14:22,530 Next e use C this is false because a and c not binding to different values 10 and 15 next B is not C 118 00:14:22,890 --> 00:14:25,360 and this should return true. 119 00:14:25,680 --> 00:14:29,340 And this is about the identity operators.