📜  Python| sympy.nT() 方法

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

Python| sympy.nT() 方法

sympy.nT()方法的帮助下,我们可以计算在 SymPy 中可以具有给定数量的部分的分区数。

示例 #1:

# import sympy 
from sympy import * 
  
items = "aaa"
k = 2
  
print("Value of k = {} and the items are = {}".format(k, items))
   
# Use sympy.nT() method 
partitions = nT(items, k)  
      
print("Partitions : {}".format(partitions))  

输出:

Value of k = 2 and the items are = aaa
Partitions : 1

示例 #2:

# import sympy 
from sympy import * 
  
items = [1, 3, 2, 5, 4]
k = 3
print("Value of k = {} and the items are = {}".format(k, items))
   
# Use sympy.nT() method 
partitions = nT(items, k)  
      
print("Partitions : {}".format(partitions))  

输出:

Value of k = 3 and the items are = [1, 3, 2, 5, 4]
Partitions : 25