Home / Computer Science / Python / Numbers in Python

Numbers in Python

Python Number data types stores numeric values (Numeric – value should be constant and never change).
The numeric types are listed as below:
These are created an immutable object, once the object is created and that never change and if the value is changed it leads to create a new object.
Obj1 = 2
Obj1 is an object assigned a value of 2, here 2 is constant and never change. If the value of number (obj1) data type is changed to other value a new object is allocated.
Obj2 = 3
Below are the examples for number data types:
x = 1
y = 3.14
z = 1+2j
If we want to know the data types of the above objects use command: type(object)
print (type(object))

>>> x=1
>>> print(type(x))
<class 'int'>
>>> y=3.14
>>> print(type(y))
<class 'float'>
>>> z=1+2j
>>> print(type(z))
<class 'complex'>

See the below code snippet

How to know Data types in Python
Data types in Python

Int type:

Integer type is a number type which don’t have decimals in that number, i.e whole number. The number may be signed or unsigned integer (Negative or positive).

>>> num1=5
>>> print(type(num1))
<class 'int'>
>>> num2=898654234545
>>> print(type(num2))
<class 'int'>
>>> num3=-969
>>> print(type(num3))
<class 'int'>

Integer Data type in Python
Integer Data type in Python

In the above code snippet num1, num2 and num3 are showing data type as integer. Even num3 having negative sign before the number.

About GSK

Hi, i am Santosh Gadagamma, a tutor in Software Engineering and an enthusiast for sharing knowledge in Computer Science and other domains. I developed this site to share knowledge to all the aspirants of technologies like, Java, C/C++, DBMS/RDBMS, Bootstrap, Big Data, Javascript, Android, Spring, Hibernate, Struts and all levels of software project design, development, deployment, and maintenance. As a programmer I believe that, "The world now needs computers to function." Hope, this site guides you as a learning tool towards greater heights. I believe that Education has no end points and i wish to learn more in the process of teaching you.

Check Also

Key words in Python

Generally, every programming language has syntax like the same python has its own syntax, key …