Easy Tutorial
❮ Python Att List Extend Python Os Unlink ❯

Python math.nan Constant

Python math Module

Python math.nan returns a floating-point value nan (not a number), which is not a valid number.

math.nan is equivalent to the output of float('nan').

Syntax

The syntax for the math.nan constant is as follows:

math.nan

Return Value

Returns a floating-point number nan.

Example

The following example returns nan:

Example

# Import math package
import math

# Print nan
print(math.nan)

# Print the type of nan
print(type(math.nan))

Output:

nan
<class 'float'>

Python math Module

❮ Python Att List Extend Python Os Unlink ❯