Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
math
nan
notanumber
communitycreator

# What is math.isnan() in python?

Eman Kashif

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The math module in Python provides access to mathematical functions and constants. math.isnan() checks whether a value is a number or not.

### Usage

Suppose you want to validate records that specify the trends in inflation. math.isnan() will be used to check if the values entered are numbers or not. This mechanism is used largely in validating systems.

### Syntax

math.isnan(x)


### Arguments

x: The value to be checked.

This parameter is required.

### Return value

The function returns a Boolean value of true if the value is not a number, and false if it is a number.

### Code

#import libraryimport math#initialize variablesa = 3b = -5.6c = math.infd = 9932.435e = +57f = 0.00004g = math.nan#Check whether variables are NaN print(a, ':', math.isnan(a))print(b, ':', math.isnan(b))print(c, ':', math.isnan(c))print(d, ':', math.isnan(d))print(e, ':', math.isnan(e))print(f, ':', math.isnan(f))print(g, ':', math.isnan(g))

RELATED TAGS

python
math
nan
notanumber
communitycreator

CONTRIBUTOR

Eman Kashif

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring

Learn in-demand tech skills in half the time 