Python Set remove() : Removes Element from the Set
We can remove elements from a set by using the discard() method. Again as we have just discussed that there is no specific index attached to the newly added element in our set.
Syntax:
Python Set add() : adds element to a set
We can add elements to a set by using add() method. Remember that, there is no specific index attached.
Syntax:
set.add(elem)
Python Set copy(): Returns Shallow Copy of a Set
Syntax:
numbers = {1, 2, 3, 4}
new_numbers = numbers
Python Set clear(): remove all elements from a set
Python Set difference() : Returns Difference of Two Sets
Syntax:
Python Set difference_update() : Updates Calling Set With Intersection of Sets
Syntax:
Python Set discard() : Removes an Element from The Set.
Syntax:
Python Set intersection() : Returns Intersection of Two or More Sets
Syntax:
A.intersection(*other_sets)
Python Set intersection_update() : Updates Calling Set With Intersection of Sets
Syntax:
A.intersection_update(*other_sets)
Python Set isdisjoint(): Checks Disjoint Sets
Syntax:
Python Set issubset(): Checks if a Set is Subset of Another Set
Syntax:
A.issubset(B)
Python Set issuperset(): Checks if a Set is Superset of Another Set
Syntax:
A.issuperset(B)
Python Set pop() : Removes an Arbitrary Element
Syntax:
Python Set symmetric_difference() : Returns Symmetric Difference
Syntax:
A.symmetric_difference(B)
Python Set symmetric_difference_update() : Updates Set With Symmetric Difference
Syntax:
A.symmetric_difference_update(B)
Python Set union() : Returns Union of Sets
The union operation on two sets produces a new set containing all the distinct elements from both the sets. In the below example the element “Wed” is present in both the sets.
Syntax:
Python Set update() : Add Elements to The Set.
Syntax:
Python any(): Checks if any Element of an Iterable is True
Syntax:
Python all(): returns true when all elements in iterable are true
Syntax:
Python ascii(): Returns String Containing Printable Representation.
Syntax:
Python bool(): Converts a Value to Boolean.
Syntax:
Python enumerate() : Returns an Enumerate Object
Syntax:
enumerate(iterable, start=0)
Python filter(): constructs iterator from elements which are true
Syntax:
filter(function, iterable)
Python frozenset() : returns immutable frozenset object.
Syntax:
Python iter() : returns iterator for an object.
Syntax:
Python len() : Returns Length of an Object.
Syntax:
Python max() : returns largest element.
Syntax:
max(iterable, *iterables[,key, default])
max(arg1, arg2, *args[, key])
Python min() : returns smallest element.
Syntax:
min(iterable, *iterables[,key, default])
min(arg1, arg2, *args[, key])
Python map() : Applies Function and Returns a List.
Syntax:
map(function, iterable, ...)
Python set() : returns a Python set.
Syntax:
Python sorted() : returns sorted list from a given iterable.
Syntax:
sorted(iterable[, key][, reverse])
Python sum() : Add items of an Iterable.
Syntax:
Python zip() : Returns an Iterator of Tuples.
Leave a Reply