Friday, December 27, 2024
Google search engine
HomeLanguagesSymPy | Subset.cardinality() in Python

SymPy | Subset.cardinality() in Python

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

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments