Python: Sets, Union, Intersection
Difference of Sets
set1 = {1, 2, 3} set2 = {1, 4, 5} print((set2 - set1) == {4, 5}) print((set1 - set2) == {2, 3})
Union of Sets
set1 = {1, 2, 3} set2 = {1, 4, 5} print(set1.union(set2) == {1, 2, 3, 4, 5})
Intersection of Sets
set1 = {1, 2, 3} set2 = {1, 4, 5} print(set1.intersection(set2) == {1})
Python, Data Structure
- Python: List
- Python: Generate List: range
- Python: List Comprehension
- Python: List Methods
- Python: Iterate List
- Python: Map f to List
- Python: Filter List
- Python: Iterator to List
- Python: Copy Nested List, Shallow/Deep Copy
- Python: Interweave Lists to Tuples, Transpose
- Python: Sort
- Python: Convert List to Dictionary
- Python: Dictionary
- Python: Iterate Dictionary
- Python: Dictionary Methods
- Python: Tuple
- Python: Sets, Union, Intersection
- Python: Sequence Types
- Python: Read Write JSON