Skip to playerSkip to main content
  • 6 months ago
In Python, a dictionary stores data as key-value pairs. Each key within a dictionary must be unique and immutable, meaning it cannot be changed after it's created. Common data types used for keys include strings, numbers, and tuples

Category

📚
Learning
Transcript
00:00There is a small concept that I had to iterate on the definition, but I thought that you can clear that the dictionary's keys are immutable.
00:12The immutable data types of data types, you can replace them.
00:18For example, string is a immutable data type.
00:23You can replace it.
00:33This is a single pair of dictionary.
00:38You can replace it.
00:44If I run it, it's quite happy.
00:47The key is immutable.
00:57The key is immutable.
01:00The immutable data type is false.
01:04We have false.
01:06We see false.
01:09Nice.
01:10However, one thing we have noted is that the list is mutable.
01:15It is immutable.
01:16We have indexing and change the value.
01:19The list is equal to 1, 2, 3.
01:26One, two, three.
01:27So, I would say that the list of index is zero.
01:33I would not assign value to 2.
01:36I would say that.
01:37How was it possible?
01:39The list is immutable.
01:41I would say that the string is immutable.
01:45Basically, the dictionary is the key is immutable.
01:50Now, because the list is immutable,
01:52you can say that one of this list is equal to this thing.
01:57Now, I will run it.
01:59It's mad on me.
02:00Okay.
02:01It's a unhashable type.
02:05You cannot add this thing.
02:07Okay.
02:08Interesting.
02:09So, you can use any key, any data type except which is mutable.
02:19Which is mutable.
02:20The change is not.
02:21Okay.
02:22A small thing is to have to use which type is best.
02:29Of course, you will know what experience is.
02:32Which type is best.
02:36Imagine you have to develop a game.
02:38Now, we're in game today we have a player of countryاشita save.
02:46We're in this new movement,
02:47We,...
02:48Now, we have the list node the circle which � client.
02:50You can use characteristics...
02:51Characteristics.
02:52Ok.
02:53Carestan is ...
02:54Characteristics...
02:55א...
02:57Characteristics.
02:58And ...
02:59Characteristics is a name to have a group.
03:01Let's call...
03:02Let's say power,
03:05let's say power
03:07ठीक है और उसके पास
03:09let's say bonus है
03:11and so on
03:13however
03:14this is not
03:18the property
03:19is not the property तरीका exist
03:21करता है और वो
03:22basically इसको dictionary में आप define कर सकते है
03:25तो आप कहें dictionary
03:26ठीक है is equal to
03:28एक नई dictionary आप define करने लगा है
03:30उसकी खासित यह है
03:33कि आप उसमें कहते हैं player
03:34ठीक है, key is equal to, अब जरा आपने गवर करना है, player, और player करने हैं, let's say, john, या name, ठीक है, उसके साथ, power,
03:52full, अब देखिए, यह मज़ीद descriptive हो गया न, अब मैं, for example, मैं कहता हूँ, bonus, ठीक है,
04:08two lives, अब मज़ीद descriptive हो गया न, और अब मैं easily, जब भी dictionary की player के, let's say, power call करूंगा,
04:21तो मुझे उसका status देगा, कहेगा powerful, अजी, however, जो list है, उसके अंदर यह ऐसा descriptive नहीं है,
04:30यह एक छोटी सी example दिया है, कि कौन सी application के लिए कौन सा data structure बहतर है,
04:35तो आपने इस बात से, इस अवाले से mindful रहना है, कि list हो, यह dictionaries हो, यह application specific है,
04:44यह ऐसा नहीं है, कि dictionary अच्छी होती है list से, और list अच्छी होती है dictionary से,
04:49कोई list मारी, कोई list के साथ, यह तो नहीं है, को personal friendship है,
04:54basically, अगर हमने एक data structure को preference देनी है, on the other data structure, as a developer,
05:01तो हमें पता होना चाहिए, कि यह list application के लिए suitable है, ठीक है न, तो इस बात का दियान रखने,
Be the first to comment
Add your comment

Recommended