SymPy | Python中的 Subset.subset()
Subset.subset() :subset()是一个 sympy Python库函数,它返回当前实例表示的子集。
Syntax :
sympy.combinatorics.subset.Subset.subset()
Return :
the subset represented by the current instance.
代码 #1:subset() 示例
# Python code explaining
# SymPy.Subset.subset()
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
# Using from
# sympy.combinatorics.subset.Subsets.subset()
# Creating Subset
a = Subset(['c', 'd'], ['geek', 'for', 'c', 'd'])
# subset value
print ("Subset a subset : ", a.subset)
输出 :
Subset a subset : [‘c’, ‘d’]
代码 #2:subset() 示例
# Python code explaining
# SymPy.Subset.subset()
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
# Using from
# sympy.combinatorics.subset.Subsets.subset()
# Creating Subset
a = Subset([2, 3, 4], [1, 2, 3, 4, 5])
# subset value
print ("Subset a subset : ", a.subset)
输出 :
Subset a subset : [2, 3, 4]