manyspikes

Data types

Initialising environment...

In the previous sections we have seen how variables can be used to work with data. But what sort of data can we work with in Python?

Python supports a variety of data types out of the box, such as:

  • Numeric types (e.g. integers, floats)
  • Text (sequences of characters)
  • Boolean data (True or False)

You can check the type of any value in Python by using the type function:

quantity = 42 print(type(quantity))

This will print int, as the value 42 is an integer.

You can also assign the result of the type function to a new variable:

quantity_type = type(quantity)

Instructions

Define a variable called unit_cost and set it to the value 4.99. Then, create a variable called unit_cost_type and set it to the type of the unit_cost variable.