-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy path4_sets.py
56 lines (41 loc) · 1.18 KB
/
4_sets.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#set_variable_name = set(<iterable>)
#Caveat while initializing an empty set
vegetables = set()
print(type(vegetables))
vegetables = {}
print(type(vegetables))
vegetables = {"Potatoes", "Carrots", "Cauliflower", "Broccoli", "Bell Pepper"}
print(vegetables)
print(type(vegetables))
vegetables = set(["Potatoes", "Carrots", "Cauliflower", "Broccoli", "Bell Pepper"])
print(vegetables)
print(type(vegetables))
vegetables = set("Potatoes")
print(vegetables)
print(type(vegetables))
#Mixed datatype set
vegetables = {"Potatoes", "Carrots", "Cauliflower", "Broccoli", "Bell Pepper", 12}
print(vegetables)
#vegetables = {"Potatoes", "Carrots", "Cauliflower", "Broccoli", "Bell Pepper", [1,2]}
#lst = [1,2]
#print(lst.__hash__())
#num = 1
#print(num.__hash__())
vegetables.remove(12)
print(vegetables)
#vegetables.remove(12)
#print(vegetables)
vegetables.discard(12)
print(vegetables)
vegetables2 = set()
vegetables2.add("Egg Plant")
vegetables2.add("Sweet Potatoes")
vegetables2.add("Green Beans")
print(vegetables2)
print(vegetables | vegetables2)
vegetables2.add("Potatoes")
print(vegetables2)
print(vegetables & vegetables2)
print(vegetables - vegetables2)
vegetables2.pop()
print(vegetables2)