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.
>>> a=50 >>>print(a,"is of type",type(a)) 50 is of type <class 'int'> >>>a=5.0 >>>print(a,"is of type",type(a)) 5.0 is of type <class 'float'> >>>a=5+6j >>>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 .
>>>x=1234567890987654321 >>>x 1234567890987654321 >>> y=0.1234567890987654 >>>y 0.1234567890987654 >>>z=5+6j >>>z
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.
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc