Thursday, December 11, 2025
HomeLanguagesPython | sympy.binomial() method

Python | sympy.binomial() method

With the help of sympy.binomial() method, we can find the number of ways to choose k items from a set of n distinct items. It is also often written as nCk, and is pronounced “n choose k”.

(1)    \begin{equation*}     \binom{N}{k} \end{equation*}

Syntax: binomial(N, K)

Parameters:
N – It denotes the number of items to choose from.
K – It denotes the number of items to choose.

Returns: Returns the number of ways to choose K items from a set of N distinct items

Example #1:




# import sympy 
from sympy import * 
  
N = 4
K = 2 
print("N = {}, K = {}".format(N, K))
   
# Use sympy.binomial() method 
comb = binomial(N, K)  
      
print("N choose K : {}".format(comb))  


Output:

N = 4, K = 2
N choose K : 6

Example #2:




# import sympy 
from sympy import * 
  
N, K = symbols('A B')
  
print("N = {}, K = {}".format(N, K))
   
# Use sympy.binomial() method 
comb = binomial(N, K)  
      
print("N choose K : {}".format(comb))  


Output:

N = A, K = B
N choose K : binomial(A, B)
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32440 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6811 POSTS0 COMMENTS
Nicole Veronica
11950 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12023 POSTS0 COMMENTS
Shaida Kate Naidoo
6942 POSTS0 COMMENTS
Ted Musemwa
7193 POSTS0 COMMENTS
Thapelo Manthata
6889 POSTS0 COMMENTS
Umr Jansen
6880 POSTS0 COMMENTS