Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:11,090 --> 00:00:13,250
I run and welcome in this new video.
2
00:00:13,880 --> 00:00:21,590
In this video, we're going to talk about dictionaries and dictionary in Python is a very interesting
3
00:00:21,590 --> 00:00:22,100
object.
4
00:00:23,000 --> 00:00:32,190
It will also allow us to store different value in a same verbal as for the list.
5
00:00:32,390 --> 00:00:40,160
But instead of the list, a dictionary is not indexing by number from zero to end, for example.
6
00:00:41,390 --> 00:00:48,200
Indeed, when you create a dictionary, you need to put the value in the dictionary.
7
00:00:48,560 --> 00:00:58,190
And for each venue, you need to put the associate key, which is a string containing the name of this
8
00:00:58,190 --> 00:01:03,440
value, and it is name the key of the value in the dictionary.
9
00:01:05,390 --> 00:01:18,230
Very, very important things to note, which is that in a dictionary, you can only put a key one time.
10
00:01:20,150 --> 00:01:25,790
So let us begin to code something for the dictionary.
11
00:01:26,240 --> 00:01:39,590
If I want to intonation a nympho dictionary, I will put the name of their variable and a 90 per of
12
00:01:39,590 --> 00:01:40,100
brothels.
13
00:01:42,920 --> 00:01:52,700
If I want to incised a dictionary with this time value, we need to put
14
00:01:56,180 --> 00:02:02,060
the coin of this value and then the value itself.
15
00:02:03,590 --> 00:02:06,950
So for each value, we need to specify.
16
00:02:14,300 --> 00:02:14,630
So.
17
00:02:16,100 --> 00:02:30,500
The venue and the key associated to this venue, and it is important to note, puts the same key military
18
00:02:30,560 --> 00:02:32,300
part time, because if
19
00:02:35,840 --> 00:02:43,340
I put the same key more than one time, I would have an issue.
20
00:02:43,400 --> 00:02:45,680
For example, if I want to
21
00:02:48,530 --> 00:02:49,970
put that so.
22
00:02:55,270 --> 00:03:06,790
We can see that we have met three values here, and it is not an issue, but it is more.
23
00:03:12,580 --> 00:03:22,450
Problematic than usual issue, because if you don't know how a dictionary work, you will have some
24
00:03:23,230 --> 00:03:31,780
error when you are going to could and if you use a dictionary in a rhythmic trading strategy, you can
25
00:03:31,840 --> 00:03:32,860
lose money.
26
00:03:33,400 --> 00:03:45,940
So while we have only two value here instead of three sets, initially, it is because when you put
27
00:03:47,440 --> 00:03:54,650
a key two times, Python takes only the last value.
28
00:03:54,670 --> 00:04:01,950
So if I put here under him, I will have I'm doing for Tesla.
29
00:04:02,410 --> 00:04:04,750
So the first venue he.
30
00:04:07,230 --> 00:04:13,020
He's not taking into account by Python, so.
31
00:04:17,150 --> 00:04:19,190
I will delete this line.
32
00:04:20,750 --> 00:04:30,020
And now we are going to add some value in a dictionary, so it is very simple to do it.
33
00:04:30,050 --> 00:04:37,970
We need to specify in a pair of brackets the key of the venue.
34
00:04:41,330 --> 00:04:47,090
And then we put just the value that we won't have to the dictionary.
35
00:04:53,730 --> 00:05:06,970
Then we can also change of venue, for example, if I want to change the value of Microsoft, I have
36
00:05:06,970 --> 00:05:11,700
just to do exactly the same could because if.
37
00:05:14,180 --> 00:05:17,270
The key is not in the dictionary.
38
00:05:17,630 --> 00:05:22,280
It will create a new venue, but have never seen before.
39
00:05:23,480 --> 00:05:32,850
If the venue is already in the dictionary, it will only change the value.
40
00:05:32,870 --> 00:05:41,960
So if I put three firms in here, it just change the value of Microsoft.
41
00:05:43,730 --> 00:05:53,900
So if you want to extract the price, you need to put the name of the dictionary, then a pair of brackets.
42
00:05:54,590 --> 00:06:01,850
And in this bear bracket, the name of the key associate to the value that you want to extract from
43
00:06:01,850 --> 00:06:02,630
the dictionary.
44
00:06:04,250 --> 00:06:04,610
So.
45
00:06:07,660 --> 00:06:14,380
And we can also see how to delete a value
46
00:06:18,010 --> 00:06:22,630
and to do it is exactly the thing has for the list.
47
00:06:22,780 --> 00:06:36,550
So we used to then operator and then you put the name of the dictionary, then a pair of brackets and
48
00:06:36,550 --> 00:06:45,100
instead of their number from the list, we need to put the key for the dictionary.
49
00:06:48,460 --> 00:07:00,070
So now we are going to see very quickly two interesting function for the dictionary, which are keys
50
00:07:00,070 --> 00:07:00,820
and values.
51
00:07:03,370 --> 00:07:16,630
The key function, which allows us to extract all the key in a dictionary, and it is very interesting
52
00:07:16,900 --> 00:07:30,610
some time, for example, to understand that the number of the venue in a dictionary or to have more
53
00:07:30,610 --> 00:07:41,530
information about this dictionary because the key is a string so we can extract some information.
54
00:07:41,890 --> 00:07:52,990
For example, here, if we extract the key, we can understand that these dictionary contain price inside
55
00:07:52,990 --> 00:07:53,740
of a list.
56
00:07:54,040 --> 00:08:02,680
If we extract the index, we have zero one two three four five, etcetera, and then we can extract
57
00:08:02,680 --> 00:08:08,020
also the value, this time using the function of ventures.
58
00:08:10,990 --> 00:08:23,350
So again, we have seen a lot of things, and it is very important to play with this method to really
59
00:08:23,380 --> 00:08:24,100
master it.
5946
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.