Different kinds of data

data-visualization.jpg

Consider the following (non-polite) conversation… probably a chat with an early AI:

Note that every response is a different sort of information:

When we want to communicate with a computer it is important to input the information in the correct format. In some programming languages you have to inform the type of data that you are storing under certain name. This is known as declaration of variables.

In python, variables don't need to be declared since the interpreter would do it for us. However, the disadvantage is that every time we want to process variables, the interpreter has to check that the variables we are using are compatible. Such checking makes the execution of the python program slower than those written in other languages.

Let's discuss a few of the available data types in python.

Strings

Strings are sequences of character, like the sentence in the dialogue above. Strings are delimited by single quote, 'This is a string', double quotes, "Another example of string", or triple quotes for strings that extend over several lines, for example:

"""
This strings is not composed by a sentence.

It is really a couple of paragraphs.
"""

Strings can be concatenated using the plus sign +, e.g.

'This is a string' + "Another example of string"

Yields the string "This is a stringAnother example of string". Note that no space is added. We used concatenation of strings in a previous post.

There are other interesting operations that we can do with strings, but we'll mention more in the future.

Numerical data

In mathematics there are various types of numbers: natural (\(\mathbb{N}\)), integers (\(\mathbb{Z}\)), reals (\(\mathbb{R}\)), complex (\(\mathbb{C}\)), among others.

In computer science it is the same. The main two are integers (int) and reals (float), which in short are whole numbers and numbers with decimals respectively.

IMPORTANT:

  • If you write the decimal point after a whole number, e.g. 10., the interpreter would assume the number is a float.
  • Arithmetical operations can take both int and float variables. However, the result of mixed operations is always a float. Example: 4 + 5.0 = 9.0.
  • Numbers written between quotes are interpreted as strings. Hence, "5.64" is not a number, it is a string. If you want to use that variable as a number, you have to cast (transform) it into float. This is indispensable when a program requires input from the user.

Lists

List are collection of several values, delimited by square brackets, and separated by commas. Each entry can be of different type, i.e., we can mix strings, numbers or other data types (even other lists).

The following are examples of lists:

shopping_list = ["apple", "banana", "carrot", "chocolate"]
weird_list = [4.21, "2", "my_name", [1, 2, 3], True]

Note that our weird_list is composed by elements of many types. Its last element is part of what is known as booleans.

A very important feature of lists is that they are iterable, i.e. you can go over its entries one by one. For example:

shopping_list = ["apple", "banana", "carrot", "chocolate"]
print("I need to buy:")
for item in shopping_list:
    print("-", item)
I need to buy:
- apple
- banana
- carrot
- chocolate

Dictionaries

A dictionary is a collection of words tied with their definitions. In python a dictionary is a collection of pairings. The word is called key, and its definition is named value.

Python dictionaries are delimited by curly brackets. Example:

definitions = {"a": "first letter of the Latin alphabeth",
               "b": "second letter of the Latin alphabeth"}

Booleans

Boolean refers to a data type in computing that can hold one of two values: True or False. It is named after mathematician George Boole, who developed the principles of Boolean logic, which is fundamental to computer programming and digital circuits.

Boolean are the data type we get when comparing things. For example: if someone asks you "Are you legal age?", or paraphrasing "Is your age greater than 18?", the possible responses are True or False.

Hence, booleans are useful for making decisions.

Boolean logic or algebra, allows us to combine conditions and building complex chains of decisions.

Wrapping up

In programming, just like in any conversational language, there are different types of information data, known as data type. Each of these data types possesses specific properties, and allows us to achieve certain goals.

in the future we shall introduce other data types.

Author: Oscar Castillo-Felisola

Created: 2026-04-02 Thu 14:59