Python Set - issubset method

The issubset() method of set class tests whether every element of the set is also present in the other set and returns a Boolean value. True if the set is found to be the subset. False otherwise.

Set Updated 15 Sep 2016 1 min read

Method signature

issubset(anotherSetObject_in)

Overview

  • The issubset() method determines whether the set is a subset of another set passed as the parameter.

Parameters

anotherSetObject_in : a Python set object.

Return Value

True: When every element in the set is also present in anotherSetObject_in.

False: When every element in the set is not present in anotherSetObject_in.

Example

python
# Example Python program that finds whether

            # a set is a subset of another given set

computerSciencePapers = {"Operating System Design", "Compiler Design","Programming Languages"}

            mechanicalEngineeringPapers  = {"IC Engine Design", "Workshop Management"}

            result = computerSciencePapers.issubset(mechanicalEngineeringPapers)

            print(result)

Output

Output
False