CS 1301 Chapter Notes - Chapter 20: Call Graph, Memoization
Document Summary
Mapping type- data type comprised of collection of keys and associated values; python"s built- in mapping type is dictionary. Dictionaries- another kind of compound type; python"s built in mapping type; map keys, which can be immutable type, to values, which can be any type just like elements of list or tuple. Keys- immutable type; data item that is mapped to value in dictionary; used to look up values in dictionary; each key must be unique across dictionary. Key: value pairs- adding these to empty dictionaries. 20. 2 dictionary methods: del- statement removes key: value pair from dictionary, len- function also works on dictionaries; returns number of key: value pairs. View- object with similarities to range object we saw earlier: values- returns view object which can be turned into list. Item- also returns view, which promises list of tuples; one tuple for each key: value pair. In and not in- test if key is in dictionary.