Kernel: Python 3 (Anaconda)
In [3]:
set()
{'o', 'h', 'e', 'l'}
{'c', 'd', 'b', 'a'}
{0, 1, 64, 4, 36, 9, 16, 49, 81, 25}
<class 'set'>
In [2]:
dict
In [5]:
{'daddy', 'mum', 'hello'}
In [6]:
3
In [7]:
True
In [8]:
False
In [10]:
{1, 3, 5, 7, 9, 11, 13, 15, 17, 19}
{0, 2, 4, 6, 8, 10, 12, 14, 16, 18}
set.isdisjoint(other) - истина, если set и other не имеют общих элементов.
In [11]:
True
In [12]:
True
set.union(other, ...) или set | other | ... - объединение нескольких множеств.
In [13]:
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}
set.intersection(other, ...) или set & other & ... - пересечение
In [14]:
set()