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

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)


My Personal Notes arrow_drop_up

Coder Machine Learner Social Activist Vocalist

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.