Python math.perm() Method

Math Methods : Find the number of ways to choose k things from n items

Definition and Usage

The math.perm() method returns the number of ways to choose k items from n items with order and without repetition.

Note: The k parameter is optional. If we do not provide one, this method will return n! (for example, math.perm(7) will return 5040).

Syntax

math.perm(n, k)

Parameter Values

Parameter Description
n Required. Positive integers of items to choose from
k Optional. Positive integers of items to choose

Note: If k is greater than n, it returns 0.

Note: If n or k are negative, a ValueError occurs. If n or k  are not integers, a TypeError occurs.

Technical Details

Return Value: An int value, representing the number of ways to choose k items from n items with order and without repetition
Python Version: 3.8