=>Dictionary is like a list , contains a collection of indices , called keys and their corresponding values.
*Mapping : A dictionary represents a route/map
from keys to values.
The elements of a dictionary are never indexed
with integers
Python dictionaries use a data structure called a
hashtable
=>There are 3 ways to count how many times a letter appears and the best way is implementing through dictionaries
Dictionaries have a method called "get" that takes a key and a default value.
=>Traverses the keys of the dictionary is possible by us
ing dictionary in a for statement.
=>Lookup : The operation lookup means finding the corresponding value of a key in dictionary i.e., by value v = d[k].
Reverse lookup is nothing but finding the
corresponding key of a value.
The raise statement causes an exception; in<br>
this case it causes a LookupError.
You can provide a detailed error message as<br>
an optional argument , when you raise an<br>
exception.
A reverse lookup is much slower than a forward
lookup.
=>Lists can be values in a dictionary, but they cannot be keys.
In the inverted dictionary there are several hits's
of having same vales which are in "List" see
below example
* hist = histogram('parrot')
>>> hist
{'a' :1,'p':1,'r':2,'t':1,'o':1}
>>>inverse = invert_dict(hist)
>>>inverse
{1: ['a','p','t','o'], 2: ['r']}
**A hash is a function that takes a value and
returns an integer.
**if the keys are mutable, like lists, the dictionary
wouldn’t work correctly.
=>A previously computed value that is stored for later use is called a memo.
=>If a global variable refers to a mutable value, you can modify the value without declaring the variable:
=>There are four types of debugging
Scale down the input
Check summaries and types
Write self-checks
Format the output