Open In App
Related Articles

SymPy | Subset.cardinality() in Python

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
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


Last Updated : 26 Aug, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads