# How to check if a variable is a number in Python

> Learn how to check if a variable is a number in Python using type() or isinstance() to compare it against the int class, or float for floating point numbers.

Author: Flavio Copes | Published: 2021-03-02 | Canonical: https://flaviocopes.com/python-check-number/

You can check if a variable is an integer using the `type()` function, passing the variable as an argument, and then comparing the result to the `int` class:

```python
age = 1
type(age) == int #True
```

Or using `isinstance()`, passing 2 arguments: the variable, and the `int` class:

```python
age = 1
isinstance(age, int) #True
```

You can check if the number is a floating point number by comparing it to `float` instead of `int`:

```python
fraction = 0.1
type(fraction) == float #True
```
