#9 Python :- Sets, Boolean
Sets:-
A set is created by placing all the items (elements) inside curly braces {}, separated by comma, or by using the built-in set() function.
e.q. myset= {1, 2, 3} or set(1, 2,3)
Properties:-
i) Immutable:- We can not change the values of sets . however we can add or remove by using .add() and .remove syntax.
ii)Unique:- Every elements inside a set is always unique.
e.q. myset= set(1,1,1,2,2,2,2,2,3,3,3,3,3,5,5,5,5,)
print(myset) -----> {1, 2, 3, 5}
iii) Unordered:- We can't do indexing and slicing of set.
Boolean:- It is just checking the given situation is true or false.
e.q. a) 1>2 ----> False
b) 5>3 -----> True
c) 7==7 -----> True
d) 7>=7 -----> True
Comments
Post a Comment