>>> hash("dsfdfasd") 4008608082288030192 >>> hash("dsfdfase") -2996068020242219814 >>> hash((1,2,3)) 529344067295497451 >>> hash([1,2,3]) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'list' >>> # mutable objects are not hashable >>> >>> s = set() >>> s set() >>> len(s) 0 >>> s.add("a") >>> s {'a'} >>> s.add(True) >>> s {True, 'a'} >>> print(s.add("b")) None >>> s {True, 'a', 'b'} >>> s.add("b") >>> s {True, 'a', 'b'} >>> # sets do noot ahve duplicates, per == >>> # no control over order in which items are presented >>> "b" in s True >>> "quack" in s False >>> s = {"a", "b", "c", "e", "m"} >>> t = {"b", "e", "n", "p", "r"} >>> s {'c', 'e', 'b', 'm', 'a'} >>> t {'p', 'r', 'e', 'b', 'n'} >>> s & t {'e', 'b'} >>> s.intersection(t) {'e', 'b'} >>> s & t {'e', 'b'} >>> s.intersection(t) {'e', 'b'} >>> s | t {'c', 'b', 'm', 'a', 'n', 'p', 'r', 'e'} >>> s.union(t) {'c', 'b', 'm', 'a', 'n', 'p', 'r', 'e'} >>> ## union is combined memembershiip of A and B. >>> s - t {'m', 'c', 'a'} >>> s {'c', 'e', 'b', 'm', 'a'} >>> t {'p', 'r', 'e', 'b', 'n'} >>> s.difference(t) {'m', 'c', 'a'} >>> ## relative complement >>> s ^ t {'p', 'r', 'c', 'n', 'a', 'm'} >>> s {'c', 'e', 'b', 'm', 'a'} >>> t {'p', 'r', 'e', 'b', 'n'} >>> (s | t) - (s & t) {'c', 'm', 'a', 'n', 'p', 'r'} >>> s.add([1,2,3]) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'list' >>> # A and B are disjoint if they have an empty intersection >>> s.isdisjoint(t) False >>> s & t {'e', 'b'} >>> s < t False >>> t < s False >>> s == t False >>> # s <= t means every element of s belongs to t. >>> # s is a subset of t >>> # s < t means every element of s belongs to t but s != t >>> s.discard("e") >>> s {'c', 'b', 'm', 'a'} >>> s.discard("b") >>> s {'c', 'm', 'a'} >>> s.isdisjoint(t) True >>> hash(s) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'set' >>> d = {} >>> d["morrison"] = "computer scince" >>> d["teague"] = "mathematics" >>> d["vazquez"] = "mathemtics" >>> >>> d["vazquez"] = "mathematics" >>> d {'morrison': 'computer scince', 'teague': 'mathematics', 'vazquez': 'mathematics'} >>> d.keys() dict_keys(['morrison', 'teague', 'vazquez']) >>> list(d.keys()) ['morrison', 'teague', 'vazquez'] >>> list(d.values()) ['computer scince', 'mathematics', 'mathematics'] >>> for k in d.keys(): print(k) ... morrison teague vazquez >>> for k in d.keys(): print(d[k]) ... computer scince mathematics mathematics >>> # keys in dictionaries must be hashable >>> # elements of sets must be hashable. >>> # hashing makes these structures highly efficient. >>> >>> #worker statment >>> # grammatically complete sentence. >>> # boss steament is grammatically incomplete >>> # can alter the flow of executions. >>> # As of now our progams run in seriatum. >>> quit()