Home »
Python
math.nan constant with example in Python
Python math.nan constant: Here, we are going to learn about the math.nan constant of math module with example in Python.
Submitted by IncludeHelp, on April 19, 2019
Python math.nan constant
math.nan constant is a predefined constant, which is defined in the math module, it returns floating-point nan (Not a Number), which is equivalent to float('nan').
Note: math.nan constant is available from Python 3.5
Syntax of math.nan constant:
math.nan
Return value: float It returns a float value (nan) – that is the floating-point "Not a Number".
Example:
Input:
print(math.nan)
Output:
nan
Python code to demonstrate example of math.nan constant
# python code to demonstrate example of
# math.nan constant
# importing math module
import math
# printing value of nan
print("value of NaN = ", math.nan)
Output
value of NaN = nan
Reference: Python math library