Saturday 20 June 2020

Python Dictionaries


Understanding Dictionaries

Dictionary is the most handy data type offered by Python and frequently used when the items are needed to be accessed by special or user defined keys.

Dictionaries are quite similar to the lists in the following ways:

Mutable: Like lists, dictionaries are also mutable,

Can contain any type of data types like lists.


But differ from the lists in the following ways:

Dictionaries do not support numeral indexing like lists do. However, you can access the items with their respective keys.

Keys in dictionaries are of immutable type unlike lists, where keys simply mean the positions of the items.

 

Dictionary as map

Dictionary consists of collection of the key-value pairs. It works as a map data structures in other programming languages. Dictionary maps the value to its associated key.

Restriction with keys

Like list where positions of the items are unique, dictionary keys are also unique and of immutable type.

Creating Dictionary

Dictionary can be created by enclosing the key-value pairs inside curly braces ( { } ) like:

dict = { key:value, key:value, ….}

Creating name of the books with respective author

books_details = {

“Let us C” : “Yashavant Kanetkar”,

“TCR JAVA” : “Herbert Schildt”,

“Design and Analysis of Algorithms” : “Thomas Cormen”,

“Operating Systems” : “Peter Galvin” }

Dictionary can also be created using built-in dict( ) function:

books_details = dict( [

(“Let us C”, “Yashavant Kanetkar”),

(“TCR JAVA”, “Herbert Schildt”),

(“Design and Analysis of Algorithms”,“Thomas Cormen”),

(“Operating Systems”, “Peter Galvin”),

] ) 

Accessing Value with key

books_details[ “let us C”]

'Yashavant Kanetkar'

Referring to a key which is not present in the dictionary, Python raises an exception:

books_details[“ abc”]

 



If you try to use key as mutable type like list, Python raises exception

dict = { [“Python”, “JAVA”, “C”] : “ Programming Languages” }


 

Updating the existing value of the key

books_details[“Operating Systems”] = “Avi Silberschatz”


books_details 

{'Let us C': 'Yashavant Kanetkar', 'TCR JAVA': 'Herbert Schildt', ‘Design and Analysis of Algorithms’ : ‘Thomas Cormen’,‘Operating Systems’ : ‘Avi Silberschatz’ }

Updating is possible because dictionary values are mutable type.

 

 

How to map a Network Drive in Windows 10?


Mapping shared folder as a network drive in windows 10.

To map a shared folder as a network drive in windows 10 operating systems, you may follow the steps given below:-

Press Windows+E key to open "Computer" where all drives and partitions exists

Click on ‘This PC

On the top of the windows you can see "Map Network Drive" Icon as shown in below given screenshot:


Click on ‘Map Network Drive


Once you click on "Map Network Drive", a Pop-up window will appear and it will prompt you to give the shared folder path of the network location/folder which you want to map as a network drive in your computer.

Feed in the Folder path details and click on Finish


Now you are done with mapping network drive for your Windows 10 computer. You can see the network mapped drive in your "Computer" along with other local drives.

 

Cheers, Please write me back if you have any query of feedback on this.