Answers for "python combination number"

1

combination python

# 1. Print all combinations 
from itertools import combinations

comb = combinations([1, 1, 3], 2)
print(list(combinations([1, 2, 3], 2)))
# Output: [(1, 2), (1, 3), (2, 3)]

# 2. Counting combinations
from math import comb
print(comb(10,3))
#Output: 120
Posted by: Guest on September-30-2021
0

counting combinations python

# Counting combinations
# nCk = n! / (k!(n-k)!)
from math import comb
>>> comb(10,3)
120
Posted by: Guest on September-30-2021
-1

python choose function

>>> from math import comb
>>> comb(20,10)
Posted by: Guest on June-07-2020
0

python choose function

deck = range(1, 53) #get deck of cards from 1 to 52
comb = list(itertools.combinations(deck, 2)) # make list  with unic 2 cards combination
len(comb) #output 1326
Posted by: Guest on May-09-2020

Code answers related to "python combination number"

Python Answers by Framework

Browse Popular Code Answers by Language