This article mainly describes the Python implementation of the permutation combination of computing operations, involving Python mathematical operations related functions and the use of skills, the need for friends can refer to the following
In this paper, we describe the permutation and combination calculation operations implemented by Python. Share to everyone for your reference, as follows:
1. Call scipy to calculate the specific values of the permutation combination
>> from scipy.special import comb, perm>> perm (3, 2) 6.0>> comb (3, 2) 3.0
2. Call Itertools to get the total number of conditions for the permutation combination
>> from Itertools import combinations, permutations>> permutations ([1, 2, 3], 2) <itertools.permutations At 0x7febfd880fc0> # iterative objects >> list (permutations ([1, 2, 3], 2)) [(1, 2), (1, 3), (2, 1), (2, 3), (3, 1)] >> list (combinations ([1, 2, 3], 2)) [(1, 2), (1, 3), (2, 3)]