-
Notifications
You must be signed in to change notification settings - Fork 0
/
set.py
44 lines (42 loc) · 940 Bytes
/
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
# set is data type
# unordered collection of unique items
#s={1,2.0,"koushik",1.0}
#print(s[4])# set data type can not support indexing
#l=[1,2,3,4,5,6,7,8,8,8]
# remove duplicate using set
#s2=list(set(l))
#print(s2)
#print(dir(set))
#s.add(10)
#print(s)
#s.remove(4)
#print(s)
#s.discard(14)
#s.clear()
#print(s)
#s1=s.copy()
#print(s1)
#we can not store list,tuple in a set
# we can store interger,float,string in a set
# set can provide any output with unordered sequence
#print(s)
#for "koushik" in s:
#print("present")
#else:
#print("not present")
#for i in s:
#print(i)
#l=["a","b","c"]
# set math function()
s1={1,2,3,4}
s2={1,4,6,7}
# union
# used to combine two sets
# it only contains unique values
# we use | pipe symbol to present union
#union_set=s1|s2
#print(s1|s2)
# intersection
# which only takes duplicates element from a set
print(s1&s2)
print(type(s1))