SymPy | Python中的 Subset.size()
Subset.size() : size()是一个 sympy Python库函数,它返回子集的大小。
Syntax :
sympy.combinatorics.subset.Subset.size()
Return :
the size of the subset.
代码 #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)
输出 :
Subset a size : 2
代码 #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)
输出 :
Subset a size : 3