Python: Numeric Data Type

Python has many useful built-in data types. Python variables can store different types of data based on a variable's data type. Numeric data type represent the data which has numeric value. Numeric value can be integer, floating number or even complex numbers.

1. Integers

Integers are one of the Python data types. Its value is represented by int class. An integer is a whole number, negative, positive or zero (without fraction or decimal).


a = 5

Output: <class 'int'>

2. Floating

Floating point numbers or floats are another Python data type. Its value is represented by float class. Floats are decimals, positive, negative and zero. Floats can also be represented by numbers in scientific notation which contain exponents. The character e or E followed by a positive or negative integer may be appended to specify scientific notation.


a = 5.0

Output: float

3. Complex Numbers

 Complex number is represented by complex class. A complex number is defined in Python using a real component + an imaginary component j. The letter j must be used to denote the imaginary component.


a = 23 + 3j

Output: <class 'complex'>