-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay13.py
More file actions
29 lines (21 loc) · 878 Bytes
/
Copy pathDay13.py
File metadata and controls
29 lines (21 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# set = collection which is unordered, unindexed. No duplicate value
utensils = {"fork", "spoon", "knife"} # create a set
dishes = {"bowl", "plate", "fork", "cup"}
print(utensils) # print utensils
print(dishes) # print dishes
utensils.add("napkin") # add napkin to set
print(utensils)
utensils.remove("fork") # remove fork from the set
print(utensils)
utensils.update(dishes) # update elmt of dishes to utensils
print(utensils)
dishes.update(utensils) # update elmt of utensils to dishes
print(dishes)
print(utensils.difference(dishes)) # find difference in utensils and dishes
print(utensils.intersection(dishes)) # intersect ie common elemt in set
dinner_table = utensils.union(dishes) # create new variable
print(dinner_table)
for x in dinner_table:
print(x)
utensils.clear()
print(utensils)