Python Tutorial Python Advanced Python References Python Libraries

Python math - nan



The Python math.nan is used to return a floating-point "not a number" (NaN) value. It is equivalent to the output of float('nan').

Syntax

#New in version 3.5
math.nan

Parameters

No parameter is required.

Return Value

Returns a floating-point "not a number" (NaN) value.

Example:

The example below shows the usage of math.nan.

import math

#print the value of nan
print(math.nan)

The output of the above code will be:

nan

❮ Python Math Module

5