📜  SymPy | Python中的 Subset.size()

📅  最后修改于: 2022-05-13 01:54:52.932000             🧑  作者: Mango

SymPy | Python中的 Subset.size()

Subset.size() : size()是一个 sympy Python库函数,它返回子集的大小。

代码 #1:size() 示例

# Python code explaining
# SymPy.Subset.size()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
  
# Using from 
# sympy.combinatorics.subset.Subsets.size()
  
# Creating Subset
a = Subset(['c', 'd'], ['geek', 'for', 'c', 'd'])
  
# size value
print ("Subset a size : ", a.size)

输出 :

代码 #2:size() 示例

# Python code explaining
# SymPy.Subset.size()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
  
# Using from 
# sympy.combinatorics.subset.Subsets.size()
  
# Creating Subset
a = Subset([2, 3, 4], [1, 2, 3, 4, 5])
  
# size value
print ("Subset a size : ", a.size)

输出 :