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 libraries from sympy.combinatorics import Permutation, Cycle from sympy.combinatorics.subsets import Subset # Using from # sympy.combinatorics.subset.Subsets.cardinality() # Creating Subset a = Subset([ 'c' , 'd' ], [ 'geek' , 'for' , 'c' , 'd' ]) # cardinality value print ( "Subset a cardinality : " , a.cardinality) |
Output :
Subset a cardinality : 16
Code #2 : cardinality() Example
# Python code explaining # SymPy.Subset.cardinality() # importing SymPy libraries from sympy.combinatorics import Permutation, Cycle from sympy.combinatorics.subsets import Subset # Using from # sympy.combinatorics.subset.Subsets.cardinality() # Creating Subset a = Subset([ 'c' , 'd' ], [ '23' , 'c' , 'd' ]) # cardinality value print ( "Subset a cardinality : " , a.cardinality) |
Output :
Subset a cardinality : 8