-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsets.py
More file actions
23 lines (17 loc) · 687 Bytes
/
sets.py
File metadata and controls
23 lines (17 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
""""
This module practice working with set data structure.
Sets are unordered and doesn't allow duplicate items.
"""
courses = {"Art", "Math", "History", "Art"}
print(courses)
math_courses = {"Math", "Physics", "Literature", "Discrete Math", "Differential"}
science_courses = {"Math", "Physics", "Literature", "Chemistry", "Biology"}
print(math_courses.intersection(science_courses))
print(math_courses & science_courses)
print(math_courses.union(science_courses))
print(math_courses | science_courses)
print(math_courses.difference(science_courses))
print(math_courses - science_courses)
# Empty set
# empty_set = {} # Not working. it's used for empty dictionary
empty_set = set()