Python for Beginners - 08 | Built-in Data Types | [Dictionary]

Pubblicato il: 12 agosto 2024
sul canale di: E-Skillation
25
5

[What are dictionaries] - In Python, a dictionary is a collection of key-value pairs. Will look at it to understand where this data type is useful?
[Dictionary Syntax] - To create a dictionary, we must separate all key value pairs with a comma and enclose entirely with curly brackets and give a name to it as a variable. Importantly, we can use a string, number or sets as keys in a dictionary, in other words the keys can be any immutable data type. However, values does not have any limitations, it can be of any data type. Values itself can be another dictionary, a list etc.
[Dictionary Index] - Unlike lists, which are indexed by a range of numbers, dictionaries are indexed by keys. For example, if I want to retrieve only the model from this dictionary, I can index it using the variable along with the key which is model in this case within square brackets. You may wonder how is this even working while we have keys being used as indexes? Well, for that Python uses hash table data structure to store the data under this data type.
[Hash Table] - Python uses concepts of hashing, creating a hash table and storing the data in a hash table structure for ease of access when using dictionaries.
[Mutability] - Dictionaries are also mutable. That means, it will avoid creating a new object and that is until the whole data is changed.


In questa pagina del sito puoi guardare il video online Python for Beginners - 08 | Built-in Data Types | [Dictionary] della durata di ore minuti seconda in buona qualità , che l'utente ha caricato E-Skillation 12 agosto 2024, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 25 volte e gli è piaciuto 5 spettatori. Buona visione!