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