1
00:00:00,960 --> 00:00:03,690
So what is going on in this script?

2
00:00:03,690 --> 00:00:06,960
Let me explain this one line by line.

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.

4
00:00:13,380 --> 00:00:19,980
Python does things when it finds a function call such as this one in here.

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

6
00:00:26,370 --> 00:00:30,060
which is equivalent to this list.

7
00:00:30,060 --> 00:00:36,930
So this list will go and be stored in this variable.

8
00:00:36,930 --> 00:00:41,540
So value is equal to this list.

9
00:00:41,550 --> 00:00:41,760
OK.

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,

11
00:00:53,950 --> 00:00:57,030
it will execute this line here.

12
00:00:57,180 --> 00:00:58,860
So it will assign the

13
00:01:01,750 --> 00:01:06,820
outputs of this expression to the mean variable.

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.

15
00:01:11,890 --> 00:01:14,590
So python will not execute this line.

16
00:01:14,590 --> 00:01:16,840
It will go to the next line.

17
00:01:16,900 --> 00:01:22,510
So if that was not true then it will do this thing here.

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

19
00:01:30,040 --> 00:01:33,470
something.

20
00:01:33,550 --> 00:01:36,950
So this is the current value of the mean.

21
00:01:37,060 --> 00:01:41,830
Therefore here the indentation ends.

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.

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

24
00:01:57,640 --> 00:02:00,310
statement.

25
00:02:00,310 --> 00:02:05,120
So you get that mean value for

26
00:02:05,130 --> 00:02:06,840
that list.

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

28
00:02:15,130 --> 00:02:16,720
if type of value is dict.

29
00:02:16,750 --> 00:02:17,800
Yes it's a dict.

30
00:02:17,950 --> 00:02:20,620
The men will be equal to that.

31
00:02:21,140 --> 00:02:24,030
So to the mean of the dictionary.

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.

33
00:02:33,370 --> 00:02:40,100
I said everything that is under else which means everything that is indented under else.

34
00:02:40,210 --> 00:02:42,060
So the children of else

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.

36
00:02:47,950 --> 00:02:49,520
It's independents.

37
00:02:49,570 --> 00:02:52,060
It has its own indentation level.

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

39
00:02:58,810 --> 00:03:04,640
return the mean for the dictionary, that one in there.

