Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:01,120 --> 00:00:09,940
To calculate the average of these grades we want to see if a list type has some sort of mean or average
1
2
00:00:09,940 --> 00:00:14,590
method that allows us to get the average of its values.
2
3
00:00:14,590 --> 00:00:18,810
For that we go to check with dir list.
3
4
00:00:19,150 --> 00:00:24,230
So list is the name that represents all lists.
4
5
00:00:24,910 --> 00:00:26,500
So that is the type.
5
6
00:00:26,810 --> 00:00:36,130
And this is an instance of that type, of the list type.
Dir list and let's have a quick look here.
6
7
00:00:36,130 --> 00:00:39,830
Do we have a mean or average method?
7
8
00:00:39,860 --> 00:00:47,880
I don't think, so so there's no methods of the list type to allow us to calculate the average of a list
8
9
00:00:48,120 --> 00:00:49,350
values.
9
10
00:00:49,350 --> 00:00:51,380
However that doesn't mean that it doesn't exist
10
11
00:00:51,390 --> 00:00:55,870
a mean method in Python to do that.
Mean or average
11
12
00:00:55,890 --> 00:00:59,670
it's not a method, but it can be a function.
12
13
00:00:59,760 --> 00:01:05,210
You remember the print function so print like that.
13
14
00:01:05,250 --> 00:01:15,570
You see that print doesn't need the dot notation to be used like for example the upper method did need
14
15
00:01:15,810 --> 00:01:24,450
a dot notation because upper is a method attached to the HELLO type and print is a function, it is an
15
16
00:01:24,450 --> 00:01:30,990
independent function that works with many types,
not only strings, not only integers, float.
16
17
00:01:31,050 --> 00:01:33,260
You can print anything with print.
17
18
00:01:33,350 --> 00:01:37,410
That's why it's not attached to a specific type.
18
19
00:01:37,410 --> 00:01:42,030
So where do we see a complete list of functions that we can use.
19
20
00:01:42,030 --> 00:01:52,740
You can do that using dir again underscore underscore built ins underscore underscore close parentheses.
20
21
00:01:54,500 --> 00:01:55,590
And that is
21
22
00:01:58,640 --> 00:02:07,670
a complete list of what you can use built in functions and also types in Python because here you also
22
23
00:02:07,670 --> 00:02:16,020
see like the list word that we used an str, and that's basically what Python has
23
24
00:02:16,020 --> 00:02:23,810
in a nutshell so these functions, and the methods of the types such as str, and least and so on.
24
25
00:02:23,880 --> 00:02:28,140
These are actually the built in features of Python.
25
26
00:02:28,140 --> 00:02:30,660
What comes with the Python installation.
26
27
00:02:30,830 --> 00:02:37,620
We will see later that there are also libraries made
by other people for example to process images.
27
28
00:02:37,620 --> 00:02:39,570
To process pixels of an image.
28
29
00:02:39,570 --> 00:02:45,420
Python doesn't have that because that that'd be too much to be included in the Python
29
30
00:02:45,420 --> 00:02:51,900
default installation so people have come up with libraries which are still Python codes and we'll look
30
31
00:02:51,900 --> 00:02:53,020
at that later.
31
32
00:02:53,130 --> 00:03:00,030
So this external Python code that you can install as an add on, as an extension will allow you to make
32
33
00:03:00,270 --> 00:03:05,370
more operations, but the built in Python is this basically.
33
34
00:03:05,370 --> 00:03:09,120
So let me see for a mean function, or an average function.
34
35
00:03:09,120 --> 00:03:11,090
No, it's not there.
35
36
00:03:11,160 --> 00:03:14,510
Okay but there is a some function.
36
37
00:03:14,820 --> 00:03:22,230
So what we can do is, let's say my sum, don't use sum as a variable name because you can see that sum
37
38
00:03:22,250 --> 00:03:24,500
is a reserved keyword.
38
39
00:03:24,520 --> 00:03:36,810
So sum(student_grades), that will give us the sum of these three numbers, and then we want to count how many
39
40
00:03:36,810 --> 00:03:39,180
items there are in that list.
40
41
00:03:39,630 --> 00:03:42,450
So do we have a count something there?
41
42
00:03:42,450 --> 00:03:43,590
Maybe not.
42
43
00:03:43,590 --> 00:03:48,940
Well I know that there's no count method but we have this Len.
43
44
00:03:49,350 --> 00:03:53,210
Which means... You can check what it means.
44
45
00:03:56,630 --> 00:04:00,760
So return of the number of items in a container.
45
46
00:04:01,070 --> 00:04:04,050
So a list is also referred to as a container.
46
47
00:04:04,250 --> 00:04:08,450
Let's say a length equal to Len.
47
48
00:04:08,830 --> 00:04:11,370
Student grades.
48
49
00:04:11,380 --> 00:04:26,550
And then finally we can get the mean which is my sum divided by length and printout the mean, save and
49
50
00:04:26,620 --> 00:04:30,430
that is the mean value of all those three numbers.
5065
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.