Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/Symmetric-difference/Python/symmetric-difference-1.py
Normal file
12
Task/Symmetric-difference/Python/symmetric-difference-1.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
>>> setA = {"John", "Bob", "Mary", "Serena"}
|
||||
>>> setB = {"Jim", "Mary", "John", "Bob"}
|
||||
>>> setA ^ setB # symmetric difference of A and B
|
||||
{'Jim', 'Serena'}
|
||||
>>> setA - setB # elements in A that are not in B
|
||||
{'Serena'}
|
||||
>>> setB - setA # elements in B that are not in A
|
||||
{'Jim'}
|
||||
>>> setA | setB # elements in A or B (union)
|
||||
{'John', 'Bob', 'Jim', 'Serena', 'Mary'}
|
||||
>>> setA & setB # elements in both A and B (intersection)
|
||||
{'Bob', 'John', 'Mary'}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
>>> setA = set(["John", "Bob", "Mary", "Serena"])
|
||||
>>> setB = set(["Jim", "Mary", "John", "Bob"])
|
||||
>>> setA ^ setB # symmetric difference of A and B
|
||||
set(['Jim', 'Serena'])
|
||||
>>> setA - setB # elements in A that are not in B
|
||||
set(['Serena'])
|
||||
>>> # and so on...
|
||||
10
Task/Symmetric-difference/Python/symmetric-difference-3.py
Normal file
10
Task/Symmetric-difference/Python/symmetric-difference-3.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
>>> setA.symmetric_difference(setB)
|
||||
{'Jim', 'Serena'}
|
||||
>>> setA.difference(setB)
|
||||
{'Serena'}
|
||||
>>> setB.difference(setA)
|
||||
{'Jim'}
|
||||
>>> setA.union(setB)
|
||||
{'Jim', 'Mary', 'Serena', 'John', 'Bob'}
|
||||
>>> setA.intersection(setB)
|
||||
{'Mary', 'John', 'Bob'}
|
||||
Loading…
Add table
Add a link
Reference in a new issue