Numeric Data
In Python, numeric information is represented by the following three data types:
int
- the data typeint
is for integers or the numbers that don't have the decimal point.float
- the data typefloat
is for numbers with decimal points.complex
- the data typecomplex
is for the numbers that contain an imaginary value. Let's implement one of each:
PYTHON
1intVariable = 5
2floatVariable = 4.5
3complexVariable = complex(4, 3)
Now, if we want to check the type
s using the type()
function:
PYTHON
1print(type(intVariable))
2print(type(floatVariable))
3print(type(complexVariable))
The output will be:
PYTHON
1<class 'int'>
2<class 'float'>
3<class 'complex'>
xxxxxxxxxx
import cmath
intVariable = 5
floatVariable = 4.5
complexVariable = complex(4, 3)
print(type(intVariable))
print(type(floatVariable))
print(type(complexVariable))
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment