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)
See the below code snippet
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).
In the above code snippet num1, num2 and num3 are showing data type as integer. Even num3 having negative sign before the number.