# SymPy | Subset.cardinality() in Python

• Last Updated : 26 Aug, 2019

Subset.cardinality() : cardinality() is a sympy Python library function that returns the number of all possible subsets.

Syntax :
sympy.combinatorics.subset.Subset.cardinality()

Return :
number of all possible subsets

Code #1 : cardinality() Example

 # Python code explaining# SymPy.Subset.cardinality()  # importing SymPy librariesfrom sympy.combinatorics import Permutation, Cyclefrom sympy.combinatorics.subsets import Subset  # Using from # sympy.combinatorics.subset.Subsets.cardinality()  # Creating Subseta = Subset(['c', 'd'], ['geek', 'for', 'c', 'd'])  # cardinality valueprint ("Subset a cardinality : ", a.cardinality)

Output :

Subset a cardinality : 16

Code #2 : cardinality() Example

 # Python code explaining# SymPy.Subset.cardinality()  # importing SymPy librariesfrom sympy.combinatorics import Permutation, Cyclefrom sympy.combinatorics.subsets import Subset  # Using from # sympy.combinatorics.subset.Subsets.cardinality()  # Creating Subseta = Subset(['c', 'd'], ['23', 'c', 'd'])    # cardinality valueprint ("Subset a cardinality : ", a.cardinality)

Output :

Subset a cardinality : 8

My Personal Notes arrow_drop_up