-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path29setMethod.py
More file actions
60 lines (46 loc) · 1.9 KB
/
29setMethod.py
File metadata and controls
60 lines (46 loc) · 1.9 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
# Set Methods:
# isdisjoint(): This function checks if terms of the items of a given set is present in atother set.
# if present return false, if not return true.
# name1 = {"Sourav","dipanwita","Saptarshi","Shounak"}
# name2 = {"Sourav","dipanwita","Saptarshi","Shounak"}
# name3 = {"saikat", "Sourin","Sandip","Pratik"}
# print(name1.isdisjoint(name2))
# print(name1.isdisjoint(name3))
# issuperset: It returns true if all the element present in the main set else it return false.
# name1 = {"Sourav","dipanwita","Saptarshi","Shounak"}
# name2 = {"Sourav","Saptarshi","Shounak"}
# name3 = {"saikat", "Sourin","Sandip","Pratik"}
# print(name1.issuperset(name2))
# print(name1.issuperset(name3))
# issubset(): It returns true if the all element of subset present in the main set, else it return false.
# name1 = {"Sourav","Dipanwita","Saptarshi","Sourin"}
# name3 = {"saikat", "Sourin","Sandip","Pratik"}
# print(name2.issubset(name1))
# print(name3.issubset(name1))
# add()- Add of two sets. Adds the elements randomly.
# name1 = {"Sourav","Dipanwita","Saptarshi","Sourin"}
# name1.add("Sandeep")
# print(name1)
# update(): If we want to add more than one item, simply create another set or any other iterable object.
# This method used to add in into the existing sets.
# name1 = {"Sourav","Dipanwita"}
# name2 = {"Saptarshi","Sourin"}
# name1.update(name2)
# print(name1)
# remove or discard:
# name1 = {"Sourav","Dipanwita","Saptarshi","Sourin"}
# name1.discard("Sourav")
# print(name1)
# pop()- Used to remove the last item.
# name1 = {"Sourav","Dipanwita","Saptarshi","Sourin"}
# items = name1.pop()
# print(name1)
# print(items)
# del()- it's not a method, its a keyword for delete the entire set.
# name1 = {"Sourav","Dipanwita","Saptarshi","Sourin"}
# del name1
# print(name1)
# clear()- Clear the whole set and print the empty set.
# name1 = {"Sourav","Dipanwita","Saptarshi","Sourin"}
# name1.clear()
# print(name1)