@farazEskandari/

Advance opperations

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
my_set = {1, 2, 3, 4, 5, 6}
my_another_set = {1, 3, 5, 7}

print(my_set.intersection(my_another_set)) #returns same elements in both sets.
print(my_set & my_another_set) #.intersection and & sign are the same opperation.

print(my_set.union(my_another_set)) #adds all elements in both sets and remove duplicate elements.
print(my_set | my_another_set) #.union and | sign are the same opperation.

print(my_set.difference(my_another_set)) #subtracts both set from each others
print(my_set - my_another_set) #.difference and - sign are the same opperation.

print(my_another_set.difference(my_set)) #subtracts both set from each others
print(my_another_set - my_set) #.difference and - sign are the same opperation.