Python Tutorial: Dictionaries (Key-value pair Maps) Basics

Nice one..Rebloggin this..

Shafiul Azam's Weblog

Dictionary in Python is a dat type also known as map. You may be already familiar with them, if using Associative Arrays in PHP or Hash-tables in C++ or Java. You may imagine a dictionary as an array, where instead of numericalindexes (the first element of array is indexed as 0, the second element indexed by 1 and so on) you can use stringindexes. Each element of a map is accessed (or, indexed) by an unique key, and so they are known as key-value pairs. Dictionaries are not sequences, hence maintains no left-to-right order.

Dictionaries are not sequences, hence maintains no left-to-right order.

Operations

You can create a map by the declaration: var_name = {key:value}

Code after “>>>” in following examples means: you need to type the code in Python command line. Any line not beginning with “>>>” indicates an…

View original post 37 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s