Saturday , July 4 2020
Breaking News
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:
int
float
complex
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

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'> ``` 