Data types in Python

Each and every value in Python has a datatype and these data types determine what operations can be performed on that particular data.

In Python, everything is an object. Data types are classes and variables are objects (instance of the classes)

Python has various built-in data types. Let’s see the most important data types of Python here.

Python Numbers (Numeric)

Python has three categories of numbers such as integer, float, and complex number.

type() function is used to find which class a variable or a value belongs to.

**isinstance()**function is used to find if an object belongs to a particular class.

Integers – int – Positive or negative whole numbers (without a fractional part). There is no limit for integers. The only limit is due to memory availability. A floating-point number is accurate up to 15 decimal places. Example: 1 is an integer.

Floating-point numbers – float – Any real number with a floating-point representation (with a fractional part). Example: 1.0 is a float-point number.

Complex numbers – complex classes in Python – x+yj is represented as a real and imaginary component. x and y are floats and j is -1(square root of -1 called an imaginary number).

#python

Python Data Types with Examples
1.20 GEEK