WeCodeAcademy

Counting: Permutations and Combinations

How many ways can things be arranged or chosen? If order matters, count permutations: choosing a 1st, 2nd and 3rd place from 10 runners. If order does not matter, count combinations: choosing a team of 3 from 10 people.

Python's math module has both: math.perm(n, k) and math.comb(n, k).

Examplepython
Open in editor »
Quick check

Choosing a committee of 4 from 12 people, where roles are equal, is a...

Your turn: write the code

Print how many different pairs can be chosen from 8 people.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.