Math module in Python contains a number of mathematical operations, which can be performed with ease using the module.
math.perm() method in Python is used to get the number of ways to choose k items from n items without repetition and with order. It Evaluates to n! / (n – k)! when k <= n and evaluates to 0 when k > n.
This method is new in Python version 3.8.
Syntax: math.perm(n, k = None)
n: A non-negative integer
k: A non-negative integer. If k is not specified, it defaults to None
Returns: an integer value which represents the number of ways to choose k items from n items without repetition and with order. If k is none, method returns n!.
Code #1: Use of
Code #2: When k > n
Code #3: If k is not specified
Reference: Python math library
- class method vs static method in Python
- Python | os.dup() method
- Python | set() method
- Python | next() method
- Python | os.getgrouplist() method
- Python | os.fork() method
- Python | sympy RGS method
- Python | os.nice() method
- Python | os.getsid() method
- Python | os.setregid() method
- Python | os.setreuid() method
- Python | hasattr() method
- Python PIL | Kernel() method
- Python | sympy.ones() method
- Python | sympy.nC() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.