1 00:00:07,930 --> 00:00:10,045 In this question we ask, 2 00:00:10,045 --> 00:00:13,020 which of the following properly expresses the precedence of 3 00:00:13,020 --> 00:00:17,245 operators using parentheses of the following expression? 4 00:00:17,245 --> 00:00:20,659 Here we have this expression. 5 00:00:20,659 --> 00:00:25,534 So, I know that and is going to be the lowest precedence operator. 6 00:00:25,534 --> 00:00:30,415 So, this thing on the left is going to be evaluated, 7 00:00:30,415 --> 00:00:33,304 and then this thing on the right is going to be evaluated. 8 00:00:33,304 --> 00:00:36,050 So, now the question is, within these expressions, 9 00:00:36,050 --> 00:00:38,205 what gets evaluated first? 10 00:00:38,205 --> 00:00:42,790 So, multiplication has a higher precedence than comparison, 11 00:00:42,790 --> 00:00:45,440 so this is going to be evaluated first. 12 00:00:45,440 --> 00:00:50,645 So, I should know that there are parentheses around 5 times 3, 13 00:00:50,645 --> 00:00:52,895 and then we compare that to 10, 14 00:00:52,895 --> 00:00:55,730 5 times 3 is greater than 10. 15 00:00:55,730 --> 00:00:59,850 Then, we can add parentheses around this whole thing. 16 00:01:00,970 --> 00:01:04,055 Now, on the left-hand side, 17 00:01:04,055 --> 00:01:08,070 addition has a higher precedence than this comparison, 18 00:01:08,070 --> 00:01:18,640 so I should say 4 plus 6 is in parentheses and then we compare that with 11, 19 00:01:18,640 --> 00:01:22,330 and this overall expression is in parentheses. 20 00:01:22,330 --> 00:01:24,790 So, our result should look like this, 21 00:01:24,790 --> 00:01:27,980 and we can see that that's in A. 22 00:01:29,150 --> 00:01:35,130 So, let's see this example step-by-step the way that Python would evaluate it. 23 00:01:35,130 --> 00:01:37,689 So, here we have the exact same expression, 24 00:01:37,689 --> 00:01:39,715 5 times 3 greater than 10, 25 00:01:39,715 --> 00:01:42,785 and 4 plus 6 equals 11. 26 00:01:42,785 --> 00:01:45,735 So, Python sees this overall expression, 27 00:01:45,735 --> 00:01:50,835 and the first thing that it evaluates is 5 times 3 and it gets 15. 28 00:01:50,835 --> 00:01:54,105 Then, it's going to check is 15 greater than 10, 29 00:01:54,105 --> 00:02:01,460 that gets true, and then it's going to check the value of 4 plus 6 so it gets 10, 30 00:02:01,460 --> 00:02:05,135 and then it's going to ask is 10 equal to 11, 31 00:02:05,135 --> 00:02:07,475 and that's going to be false, 32 00:02:07,475 --> 00:02:13,480 and then it's going to take the value of true and false, and get false. 33 00:02:13,480 --> 00:02:19,700 So, that's how Python evaluates and breaks down this complex expression.