-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetmethod.py
More file actions
83 lines (67 loc) · 1.65 KB
/
setmethod.py
File metadata and controls
83 lines (67 loc) · 1.65 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#set methods
#day 32
#union of two sets
s={1,2,3,7,8}
s1={9,8,7,6,1,2,3}
print(s.union(s1))
s.update(s1)
print(s,s1)
city1={"pune","baramati","mumbai"}
city2={"delhi","pune","berlin"}
city3=city1.union(city2)
print(city3)
#intersection of two set
city1={"pune","baramati","mumbai"}
city2={"delhi","pune","berlin"}
city1.intersection_update(city2)
print(city1)
#symmetric diffrence
city1={"pune","baramati","mumbai"}
city2={"delhi","pune","berlin"}
city3=city1.symmetric_difference(city2)
print(city3)
#diffrence
city1={"pune","baramati","mumbai"}
city2={"delhi","pune","berlin"}
city3=city1.difference(city2)
print(city3)
#some inbuilt method
#isdisjoint() ***o/p in true or false
city1={"pune","baramati","mumbai"}
city2={"delhi","pune","berlin"}
print(city1.isdisjoint(city2))
#issuperset()
city1={"pune","baramati","mumbai"}
city2={"delhi","pune","berlin"}
city3={"kedgaon","urali","loni"}
print(city1.issuperset(city3))
#issubset()
city1={"pune","baramati","mumbai"}
city2={"delhi","pune","berlin"}
city3={"kedgaon","urali","loni"}
print(city1.issubset(city3))
#add()
city1={"pune","baramati","mumbai"}
city1.add("kedgaon")
print(city1)
#remove()
city1={"pune","baramati","mumbai"}
city1.remove("baramati") #for removing it must be in the main set
print(city1)
#discard()
city1={"pune","baramati","mumbai"}
city1.discard("kedgaon")
print(city1)
#pop()
city1={"pune","baramati","mumbai"}
item=city1.pop()
print(city1)
print(item)
#del()
city1={"pune","baramati","mumbai"}
#del city1
print(city1)
#clear()
city1={"pune","baramati","mumbai"}
city1.clear()
print(city1)