Mark As Completed Discussion

Numeric Data

In Python, numeric information is represented by the following three data types:

  1. int - the data type int is for integers or the numbers that don't have the decimal point.

  2. float- the data type float is for numbers with decimal points.

  3. complex - the data type complex 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 types 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'>
PYTHON
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment