Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python n choose r

# PYTHON 3.8
import math
math.comb(n, r)
Comment

python n choose r

# PYTHON <3.8
import operator as op
from functools import reduce

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom  # or / in Python 2
Comment

PREVIOUS NEXT
Code Example
Python :: django message framework 
Python :: python write csv line by line 
Python :: python for each attribute in object 
Python :: python list inversion 
Python :: python log transform column 
Python :: how to convert list into string in python 
Python :: leaky relu keras 
Python :: python system of nonlinear equations 
Python :: drop index in multiindex pandas 
Python :: add button to streamlit 
Python :: sort by index pandas 
Python :: find all unique items in dictionary value python 
Python :: python turn 0 into 1 and vice versa 
Python :: django import settings variables 
Python :: python pil bytes to image 
Python :: python dictionary get keys with condition on value 
Python :: crop image python 
Python :: rerun file after change python 
Python :: Scrape the text of all paragraph in python 
Python :: directory name python 
Python :: The path python2 (from --python=python2) does not exist 
Python :: sum of 1 to n number in python 
Python :: what is a module computer science 
Python :: tkinter hover button 
Python :: How can one find the three largest values of an input array efficiently, namely without having to sort the input array? 
Python :: drop multiple columns in python 
Python :: python sort list in reverse 
Python :: python get filename without extension 
Python :: get the last element of a list python 
Python :: number 1 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =