Numerical data types in PYTHON:
- Integer(123)
- Float(15.59)
- complex(3+3j)
INTEGER():
In python integers are immutable, every value creating in python is an object of an predefined class,
for example: x=123
Get Sameeramd’s stories in your inbox
Join Medium for free to get updates from this writer.
if we check for the ‘type(x)’ in the compiler then the output will be <class ‘int’>- here int is the class and number ‘123’ is the object which belongs to the class integer.
if we are converting the string into an integer using INT then the ‘int’ will be an function for example if we have to convert a string 10 into an integer 10 then- int (‘10’) here if we run this program in compiler then we will see the 10 is being changed to an integer.
As we have the integer class we have two classes called OCT () and HEX(), oct converts its integer value into octagonal form(Base 8) and hex converts its integer value into hexagonal form(Base 16)
FLOAT():
the value with an point ,the values which are after an point are called float values, in our language we call it as decimal. Float will mandatorily have a decimal value.
for example if we give ‘float(5)’ in an compiler so output will be ‘5.0'
COMPLEX():
Complex is a data type in which we have real values as well as imaginary value an imaginary value can be √-1,normally in math's we represent it as‘i’ but in python we represent it as ‘j’
for example ‘x=5+3j’ -’print(x , type(x))’then we have run it in an compiler then the output will be ‘(5+3j) <class ‘complex’>







