Error:

Create empty dictionary

d = {}

Create dictionary with elements

d = {'name': 'Alex', 'title': 'Mr'}

Add element to the dictionary

d = {'name': 'Alex', 'title': 'Mr'}
d['age'] = 33
d # {'age': 33, 'name': 'Alex', 'title': 'Mr'}

Check if dictionary is empty

d1 = {'name': 'Alex'}
d2 = {}

if d1:
    print "d1 is not empty"

if not d2:
    print "d2 is empty"

# Output: d1 is not empty, d2 is empty

Check if key is present in the dictionary

d = {'name': 'Alex', 'title': 'Mr'}
'name' in d # True
'age' in d  # False

Check if value is present in the dictionary

d = {'name': 'Alex', 'title': 'Mr'}
'Alex' in d.values() # True
33 in d.values()     # False

Delete key from dictionary

d = {'name': 'Alex', 'title': 'Mr'}
d.pop('title', None)
d # {'name': 'Alex'}
# or...
del d['name']
d # {}

Iterate over all keys of the dictionary

d = {'name': 'Alex', 'title': 'Mr'}
for key in d:
    print key

Iterate over all pairs of the dictionary

d = {'name': 'Alex', 'title': 'Mr'}
for key,value in d.iteritems():
    print '%s = %s' % (key, value)

Merge two dictionaries

d1 = {'name': 'Alex'}
d2 = {'age': 33}

d = dict(d1.items() + d2.items())
d # {'age': 33, 'name': 'Alex'}

# Python 3:
d = dict(list(d1.items()) + list(d2.items()))

Find common keys of two dictionaries

d1 = {'name': 'Alex', 'age': 33}
d2 = {'name': 'Joe', 'title': 'Mr'}
keys = []
for k in d1:
    if k in d2:
        keys.append(k)

keys # ['name']