Python sets
Python sets
Sets : A set is a wee defined collection of object .
>> Source-Code :
s = set()
print(type(s))
l = [12,76 , 25 , 98 , 28]
s_from_list = set(l)
print(s_from_list)
print(type(s_from_list))
s.add(78)
s.add(57)
#s.add(78) #It's add same number at only once because it' set
s.add(26) # IT can add differend no. at many times
s.remove(26)
print(s)
s1 = s.union({18,92,26})
print(s1)
s1 = s.intersection({34,26,18,56})
print(s1)
print(len(s))
print(min(s))
print(max(s))
s1 = [12,32,24]
print(s.isdisjoint(s1))
print(type(s1))
HAVE A GOOD DAY : )
: ) if you have any doubt in Python sets then Contact us : )
Python sets
Reviewed by Coding Guy
on
July 11, 2019
Rating:
No comments: