❮ Previous Next ❯

Python Data Types

Every value in Python has a datatype. Since everything is an object in Python programming, data types are actually classes and variables are instance (object) of these classes. Python supports many data types which are as follows:

Python Numbers

Integers, floating point numbers and complex numbers coming under Python numbers . They are defined as int, float and complex class in Python.

Basically we use the type() function to know which class a variable or a value belongs to and the isinstance() function to check if an object belongs to a particular class.

python datatype

>>> a=50
>>>print(a,"is of type",type(a))
50 is of type <class 'int'>
>>>print(a,"is of type",type(a))
5.0 is of type <class 'float'>
>>>print(a,"is complex number?",isinstance(5+6j,complex))
(5+6j) is complex number? True

Integers can be of any length, it is only limited by the memory available.

A floating point number is accurate up to 15 decimal places. Integer and floating points are separated by decimal points. 5 is integer, 5.0 is floating point number.

Complex numbers are written in the form, x + yj, where x is the real part and y is the imaginary part .

>>> y=0.1234567890987654

Here it is noted that the float variable y have truncated.

The followings are also Python data types :

The description about these data types that I have written in next article.

❮ Previous Next ❯

Follow Us


Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Email: info@silantechnology.com
      Phone: 0674-2361252
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved