-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path13. Set.py
61 lines (53 loc) · 1.04 KB
/
13. Set.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
57
58
59
60
61
# Set is an unordered collection of data, it stored multiple entries in a single variable.
# Seperated by Commas and enclosed within {}
# Sets are immutable.
# Sets do not contain Duplicate Items.
a=set()
b={2,3,4,5,2,"Tenacious",True,2.0}
print(type(a))
print(b)
for i in b:
print(i,end=",")
print("end")
if 2 in b:
print(f"Yes {2*1} is present in b")
else:
print(f"No {2*1} is not present in b")
# Manipulation
a1= {23, 22, 45, 56}
a2= {1, 2, 3, 4, 5, 6}
a1.update(a2)
a1.difference_update(a2)
a3=a1.difference(a2)
print(a3)
print(a1)
print(a1.union(a2),a1.intersection(a2))
a1.update(a2)
a3= a1.symmetric_difference(a2)
a1.intersection_update(a2)
print(a1)
print(a3)
'''
union()
update()
intersection
intersectin_update()
symmetric_difference
symmetric_difference_update()
difference()
difference_update()
'''
# IN- Built Methods
print(a1.isdisjoint(a3))
print(a1.isdisjoint(a2))
print(a1.issuperset(a2))
print(a1.issubset(a2))
a1.add(11)
a1.remove(3)
a1.discard(21)# No Error
print(a1)
a10= a1.pop()
print(a10)
del a10
a3.clear()
print(a3)