Added dictionaries section.
authorSantosh G. Vattam <vattam.santosh@gmail.com>
Fri, 18 Sep 2009 15:48:36 +0530
changeset 68 c4cfe656b57f
parent 67 5076574b7b83
child 69 5e3ce06069cf
Added dictionaries section.
basic_python/strings_dicts.rst
--- a/basic_python/strings_dicts.rst	Fri Sep 18 03:04:02 2009 +0530
+++ b/basic_python/strings_dicts.rst	Fri Sep 18 15:48:36 2009 +0530
@@ -305,3 +305,32 @@
 Dictionaries
 ============
 
+A dictionary in general, are designed to be able to look up meanings of words. 
+Similarly, the Python dictionaries are also designed to look up for a specific
+key and retrieve the corresponding value. Dictionaries are data structures that
+provide key-value mappings. Dictionaries are similar to lists except that instead
+of the values having integer indexes, dictionaries have keys or strings as indexes.
+Let us look at an example of how to define dictionaries.
+
+::
+
+  >>> dct = { 'Sachin': 'Tendulkar', 'Rahul': 'Dravid', 'Anil': 'Kumble'}
+
+The dictionary consists of pairs of strings, which are called *keys* and their
+corresponding *values* separated by *:* and each of these *key-value* pairs are
+comma(',') separated and the entire structure wrapped in a pair curly braces *{}*.
+
+**dict()**
+~~~~~~~~~~
+
+The **dict()** function is used to create dictionaries from other mappings or other
+dictionaries. Let us look at an example.
+
+::
+
+  >>> diction = dict(mat = 133, avg = 52.53)
+
+**String Formatting with Dictionaries:**
+
+String formatting was discussed in the previous section and it was mentioned that
+dictionaries can also be used for formatting more than one value like . 
\ No newline at end of file