In [2]:
# dicts are associations between keys and values notated {}
d = { 'joe': 46, 'tbones': 7 }
d


Out[2]:
{'joe': 46, 'tbones': 7}

In [3]:
d['joe'] = 27
d['joe']


Out[3]:
27

In [4]:
# each key has one value created and modified by assignment

In [5]:
# many kinds of objects can be used as keys, including strings and integers
## but not all! (e.g., lists)
d = { 1: 'one', 2: 'two' }
d[2]


Out[5]:
'two'

In [6]:
# dicts support "in" w/r/t keys
d['clam'] = 77
'airplane' in d


Out[6]:
False

In [9]:
a = ('joe', 'ctd')
b = ('stace', 'informatics')
d = dict([a,b])
d['joe'] = 'ifcb'
d


Out[9]:
{'joe': 'ifcb', 'stace': 'informatics'}

In [10]:
# strings are immutable and iterable
'python'[2:4]


Out[10]:
'th'