Python supports several numeric types such as
integer and real numbers. Integers are
represented by the int type and real numbers
are represented by the float type, which
stands for floating-point number.
The type associated with a variable depends on its value. Let's see some examples.
quantity = 12 quantity_type = type(quantity)
In the example above, the type of the variable
quantity will be int, since 12 is an
integer. So in the code above, the variable
quantity_type will be equal to int.
However, if we defined quantity to be 12.0,
which Python treats as a real number, the
type of the variable will be float.
So in the following snippet
quantity = 12.0 quantity_type = type(quantity)
the variable quantity_type is equal to
float.
Create a variable quantity of type int
and a variable unit_cost of type float.