
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Mathematical Functions in Python - Special Functions and Constants
In this article, we will learn about special functions and constants available in the math module in the Python Standard Library.
Here we will discuss some constants like −
- pi
- e
- inf
- Nan
- tau
And some functions like
- Gamma
- Isinf
- Isnan
- isfinite()
- erf()
Let's discuss constants and their respective values −
pi | 3.141592….. |
e | 2.718281…... |
inf | 6.283185…... |
nan | <infinty> |
tau | <not a number> |
Now let’s discuss some special functions and their implementation −
Gamma − return the value of gamma(n)
Isinf − checks whether the value of the function is infinity or not.
Isnan − check whether the return value is a number or not.
Isfinite − return True if the value is neither an infinity or a nan false otherwise
Erf − returns the error function of x.
Now let;’s take a look at an example −
Example
import math num=10 print (math.gamma(num)) if (math.isnan(math.nan)): print ("The number is not a number") else : print ("The number is a number") if (math.isinf(math.inf)): print ("The number is positive infinity") else : print ("The number is not positive infinity") print(math.isfinite(math.inf))
Output
362880.0 The number is not a number The number is positive infinity False
Conclusion
In this article, we learned about the Mathematical Functions in Python - Special Functions and Constants.
- Related Articles
- Python Mathematical Functions
- Mathematical Functions in Python?
- Mathematical Functions using Python
- Mathematical statistics functions in Python
- C++ Mathematical Functions
- Mathematical Functions in Java
- Mathematical Functions in C#
- Mathematical Functions in SQL
- Mathematical Constants in Python
- Program to evaluate one mathematical expression without built-in functions in python
- PHP Predefined Mathematical Constants
- Python maketrans() and translate() functions
- Decimal Functions in Python
- Operator Functions in Python
- Time Functions in Python?

Advertisements