Python Set Methods

Python has quite a few methods that set objects can all to perform frequency occurring task (related to set). For example, if you want to find intersection of two sets, you can use intersection() method.

The page contains all methods of set objects. Also, the page includes built-in functions that can take set as a parameter and perform some task.

Method Description
Python Set remove() Removes Element from the Set
Python Set add() adds element to a set
Python Set copy() Returns Shallow Copy of a Set
Python Set clear() remove all elements from a set
Python Set difference() Returns Difference of Two Sets
Python Set difference_update() Updates Calling Set With Intersection of Sets
Python Set discard() Removes an Element from The Set
Python Set intersection() Returns Intersection of Two or More Sets
Python Set intersection_update() Updates Calling Set With Intersection of Sets
Python Set isdisjoint() Checks Disjoint Sets
Python Set issubset() Checks if a Set is Subset of Another Set
Python Set issuperset() Checks if a Set is Superset of Another Set
Python Set pop() Removes an Arbitrary Element
Python Set symmetric_difference() Returns the symmetric difference of sets
Python Set symmetric_difference_update() Updates the Set with symmetric difference
Python Set union() Returns the union of sets
Python Set update() Add elements to the set
Python any() Checks if any Element of an Iterable is True
Python all() returns true when all elements in iterable is true
Python ascii() Returns String Containing Printable Representation
Python bool() Converts a Value to Boolean
Python enumerate() Returns an Enumerate Object
Python filter() constructs iterator from elements which are true
Python frozenset() returns immutable frozenset object
Python iter() returns an iterator
Python len() Returns Length of an Object
Python max() returns the largest item
Python min() returns the smallest value
Python map() Applies Function and Returns a List
Python set() constructs and returns a set
Python sorted() returns a sorted list from the given iterable
Python sum() Adds items of an Iterable
Python zip() Returns an iterator of tuples