Saturday, February 7, 2026
HomeLanguagesPython | sympy.nT() method

Python | sympy.nT() method

With the help of sympy.nT() method, we can calculate the number of partitions that can have a given number of parts in SymPy.

Syntax: nT(items, k)

Parameters:
items – An integer, a list or a string upon which partitions is to be calculated.
k – An integer specifying the number of parts that the partition should contain.

Returns: Returns the number of partitions that have given number of parts.

Example #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))  


Output:

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

Example #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))  


Output:

Value of k = 3 and the items are = [1, 3, 2, 5, 4]
Partitions : 25
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32491 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6862 POSTS0 COMMENTS
Nicole Veronica
11987 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12076 POSTS0 COMMENTS
Shaida Kate Naidoo
6996 POSTS0 COMMENTS
Ted Musemwa
7237 POSTS0 COMMENTS
Thapelo Manthata
6947 POSTS0 COMMENTS
Umr Jansen
6933 POSTS0 COMMENTS