11.07.2015 Views

Python - ACE home page

Python - ACE home page

Python - ACE home page

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Set (Mutable) & Frozenset (Immutable)>>> set, frozenset(, )>>> set() # empty setset()>>> type(set())>>> {} # not an empty set!{}>>> type({})>>> s = {1, 3, 3, 2}>>> s{1, 2, 3}>>> frozenset({1, 3, 3, 2})frozenset({1, 2, 3})>>> 3 in s, 4 in s(True, False)>>> s = set(‘yellow’)>>> t = set(‘hello’)>>> s{‘e’, ‘o’, ‘l’, ‘w’, ‘y’}>>> t{‘h’, ‘e’, l’, ‘o’}>>> s – t, s | t({‘w’, ‘y’}, {‘h’, ‘e’, ‘o’, ‘l’, ‘w’, ‘y’})>>> s & t, s^ t({‘e’, l’, ‘o’}, {‘h’, ‘w’, ‘y’}>>> {1, 3} >> help(set) >>>help(frozenset)Lecture 1221

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!