Intro to Data Types#


A data type defines what information you can save, and understanding different data types is crucial for a good code because each data type has its own set of operations.

Examples of Python data types:

  • Numeric Types: Integers (int), floating-point numbers (float), and complex numbers (complex)

  • Text Type: Strings (str) represent sequences of characters enclosed in single quotes (‘’) or double quotes (“”)

  • Boolean Type: Boolean (bool), which represents either True or False values

  • Sequence Types: Lists (list), tuples (tuple), and range objects (range)

  • Set Types: Set (set) and frozenset (frozenset), which represent unordered collections of unique elements.

  • Mapping Type: Dictionary (dict), which stores key-value pairs.

  • None Type: None, which represents the absence of a value or a null value.

Find the type#

Everytime we assign a value to a new variable, we are also indicating the data type. You can use “type()” function to identify the data type of specific variable.

# Define variables
reservoir_name = "Ross Reservoir"
<class 'str'>
depth_ft = 279
<class 'int'>
min_width_mi = 91.0
<class 'float'>
is_lake = True
<class 'bool'>


Python is a dynamically typed language, which means that variables can change their data type during runtime based on the assigned value