#sets in python
s = set()
print(type(s)) #know the type of the given function
s1 = {1,2,3,4}
s_from_list = s1 #is equal to this
print(s_from_list)
print(type(s_from_list))
s = set()
s.add(1) #for adding any set do this
s.add(1)#kitne bar bhi add kare but same number ek he bar add hoga
s.add(2) #differenct num add kr salte hai
s.remove(2) #remove the set
s.union({1,2,3}) #ek naya set banata hai
s1 = s.intersection({1,2, 3})
print(s, s1)
print(len(s)) #length of s
print(min(s)) #min num of s
print(type(s)) #type of s
s1 = {4,6}
print(s.isdisjoint(s1)) #will dis joint with s1
Comments
Post a Comment