Python supports integers, floating-point and complex numbers written as:
Let’s understand with Example –
x = 10 #int y = 10.5 #float z = 10j #complex Note :- We can check type of value using type() function as shown in code below - print(type(x)) # Result will be <class 'int'>
Int, or integer, is a whole number, positive or negative, without decimals, with unlimited length.
x = 1980
y = 5982342342
z = -8023432
Float, or “floating point number” is a number, positive or negative, containing one or more decimals. A float can also be scientific number with an “e” to indicate the power of 10.
x = 10.05
y = 56.888
z = -65.44
X = 23e45
Y = 55.7e100
Z = 132E47
Complex numbers are written with a “j” as the imaginary part.
x = 4+6j
y = 6j
z = -6j