📜  SymPy | Python中的 Subset.ksubsets()

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

SymPy | Python中的 Subset.ksubsets()

Subset.ksubsets() :ksubsets()是一个 sympy Python库函数,它按字典顺序返回大小为 k 的子集。

代码 #1:ksubsets() 示例

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

输出 :

代码 #2:ksubsets() 示例

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

输出 :