Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:00,960 --> 00:00:03,690
So what is going on in this script?
1
2
00:00:03,690 --> 00:00:06,960
Let me explain this one line by line.
2
3
00:00:06,960 --> 00:00:13,220
Python executes the function definition but it doesn't do anything because it's just a function definition.
3
4
00:00:13,380 --> 00:00:19,980
Python does things when it finds a function call such as this one in here.
4
5
00:00:19,980 --> 00:00:25,980
So here we are calling the function and the input value for that function will be a Monday temperature
5
6
00:00:26,370 --> 00:00:30,060
which is equivalent to this list.
6
7
00:00:30,060 --> 00:00:36,930
So this list will go and be stored in this variable.
7
8
00:00:36,930 --> 00:00:41,540
So value is equal to this list.
8
9
00:00:41,550 --> 00:00:41,760
OK.
9
10
00:00:42,210 --> 00:00:53,510
So what happens is that the interpreter will check if the type of that list is dict. If that is true,
10
11
00:00:53,950 --> 00:00:57,030
it will execute this line here.
11
12
00:00:57,180 --> 00:00:58,860
So it will assign the
12
13
00:01:01,750 --> 00:01:06,820
outputs of this expression to the mean variable.
13
14
00:01:06,820 --> 00:01:11,840
However this is not true in this case because type of the list is not a dict.
14
15
00:01:11,890 --> 00:01:14,590
So python will not execute this line.
15
16
00:01:14,590 --> 00:01:16,840
It will go to the next line.
16
17
00:01:16,900 --> 00:01:22,510
So if that was not true then it will do this thing here.
17
18
00:01:23,170 --> 00:01:30,040
So the men will be equal to the sum of the list divided by the length of the list which is 9.26
18
19
00:01:30,040 --> 00:01:33,470
something.
19
20
00:01:33,550 --> 00:01:36,950
So this is the current value of the mean.
20
21
00:01:37,060 --> 00:01:41,830
Therefore here the indentation ends.
21
22
00:01:41,950 --> 00:01:49,870
So return is outside of the if and else block you can see here, it has to be outside.
22
23
00:01:50,140 --> 00:01:57,430
So the conditional block ends here and the current value of the mean will be returned by the return
23
24
00:01:57,640 --> 00:02:00,310
statement.
24
25
00:02:00,310 --> 00:02:05,120
So you get that mean value for
25
26
00:02:05,130 --> 00:02:06,840
that list.
26
27
00:02:06,910 --> 00:02:15,100
If this was student grades instead what happens is that this dictionary will be stored in value and
27
28
00:02:15,130 --> 00:02:16,720
if type of value is dict.
28
29
00:02:16,750 --> 00:02:17,800
Yes it's a dict.
29
30
00:02:17,950 --> 00:02:20,620
The men will be equal to that.
30
31
00:02:21,140 --> 00:02:24,030
So to the mean of the dictionary.
31
32
00:02:24,280 --> 00:02:33,090
And if this condition is true this is executed and python will ignore everything that is under else.
32
33
00:02:33,370 --> 00:02:40,100
I said everything that is under else which means everything that is indented under else.
33
34
00:02:40,210 --> 00:02:42,060
So the children of else
34
35
00:02:42,160 --> 00:02:47,950
So to say, return of the mean is not a child of else,
it's not indented under else.
35
36
00:02:47,950 --> 00:02:49,520
It's independents.
36
37
00:02:49,570 --> 00:02:52,060
It has its own indentation level.
37
38
00:02:52,060 --> 00:02:58,810
So therefore the current value of the mean is this one
in here, so return to the mean will actually
38
39
00:02:58,810 --> 00:03:04,640
return the mean for the dictionary, that one in there.
3648
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.