Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,620 --> 00:00:06,000
Welcome back let's talk about a important term when it comes to programming.
2
00:00:06,270 --> 00:00:11,530
And that is operator precedents.
3
00:00:11,550 --> 00:00:13,030
Now what does that mean.
4
00:00:13,230 --> 00:00:17,540
Again we're using our knowledge from math class.
5
00:00:17,610 --> 00:00:28,530
It's the idea that if I do 20 plus three times four it means that different operators have precedence
6
00:00:28,590 --> 00:00:30,560
over different ones.
7
00:00:30,620 --> 00:00:40,600
That is we multiply this first equals to twelve and then 20 gets added to twelve because the Python
8
00:00:40,600 --> 00:00:44,880
interpreter is going to follow a basic set of rules.
9
00:00:45,000 --> 00:00:59,130
For example if I do 20 minus three here and let's print this out click Run I get eight because three
10
00:00:59,130 --> 00:01:06,260
times four gets evaluated first which equals to 12 and then subtracted from 20.
11
00:01:06,300 --> 00:01:14,340
It's not that this goes first and then we multiply 17 by four and this operator precedents shouldn't
12
00:01:14,340 --> 00:01:14,880
be new.
13
00:01:14,880 --> 00:01:15,210
Right.
14
00:01:15,210 --> 00:01:22,620
If you've taken any sort of math class you understand that this is how well math works and this works
15
00:01:22,620 --> 00:01:24,740
the same in all programming languages.
16
00:01:24,780 --> 00:01:28,390
So the order is this first.
17
00:01:28,590 --> 00:01:30,270
We follow the brackets.
18
00:01:30,270 --> 00:01:33,600
So whatever is wrapped in a bracket we do first.
19
00:01:33,600 --> 00:01:38,190
The second is we do the power of.
20
00:01:38,190 --> 00:01:43,410
So whatever is done in the power of will be after parentheses.
21
00:01:43,560 --> 00:01:55,970
For example if I do parentheses here and then to the power of let's say two or less two plus two to
22
00:01:55,970 --> 00:01:57,550
the power of two.
23
00:01:57,590 --> 00:02:05,950
Well the first operation that will happen is 20 minus three because that's the first precedence.
24
00:02:06,140 --> 00:02:13,890
And then we do two to the power of two because that's the next precedence and then only after we do
25
00:02:13,890 --> 00:02:16,170
that we add these two together.
26
00:02:16,170 --> 00:02:21,560
If I click Run I get twenty one which again makes sense.
27
00:02:21,580 --> 00:02:35,170
Seventeen plus four after the power of we have the multiplication and division and then finally the
28
00:02:35,170 --> 00:02:40,040
last precedence is addition and subtraction.
29
00:02:40,050 --> 00:02:42,660
Now this isn't going to be a math class.
30
00:02:42,690 --> 00:02:44,560
Some people really love math.
31
00:02:44,580 --> 00:02:46,570
Some people really don't.
32
00:02:46,710 --> 00:02:51,780
But I want to just give you this basic understanding of operator precedence.
33
00:02:51,810 --> 00:02:52,590
When you see it.
34
00:02:52,620 --> 00:02:55,400
We'll do some exercises here to get accustomed to it.
35
00:02:55,470 --> 00:02:59,880
But trust me this is as mathy as we're gonna get in this course.
36
00:02:59,880 --> 00:03:03,300
The math part of the course is well just here.
37
00:03:03,450 --> 00:03:07,900
It's gonna get a lot more interesting as we learn about different data types.
38
00:03:08,070 --> 00:03:09,390
I'll see in the next one.
39
00:03:09,420 --> 00:03:09,830
Bye bye.
3586
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.