A permutation is an arrangement in which order matters. A briefcase lock set to 3-7-4 does not open for a different ordering of those digits. Without replacement, each item can appear at most once; with replacement, repetitions such as 3-3-4 are allowed. section 2.2.3
To count ordered selections of r distinct items from n available items without replacement, multiply the choices remaining at each position: n × (n − 1) × … × (n − r + 1) = n! / (n − r)!. This requires r ≤ n. Each selection reduces the choices for the next position by one. section 2.2.3
Five items, three positions
With n = 5 and r = 3, there are 5 × 4 × 3 = 60 permutations without replacement. Python’s math.perm(5, 3) returns 60. Check the counting assumptions before using that result: allowing repeats instead gives 5³ = 125 ordered sequences, while ignoring order gives 10 combinations without replacement. section 2.2.3
>>> permutations = math.perm(n, r)
>>> print(f'Number of permutations without replacement: '
>>> f'{permutations}')
Number of permutations without replacement: 60
The Python listing computes the without-replacement count directly with math.perm(n, r). section 2.2.3








