Demo entry 6626308

2333

   

Submitted by anonymous on Jun 24, 2017 at 04:07
Language: Python 3. Code size: 547 Bytes.

from scipy.special import perm,comb
print (perm(3,2))
print (comb(3,2))
###In SCIPY there are no function like perm or comb so you need to use scipy.special

###This one could calculate the result of permutation and combination

import itertools as it
a=['beer','butter','book','truck','napkin']
print it.permutations(a,2)
###The above command could only return the location of the function in the inner
###memory so you need to list the function to obtain the result.
print list(it.permutations(a,2))
print list(it.combinations(a,2))

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).