Intro to Programming: What Are Different Data Types in Programming?

Let's explore data types more in-depth.
By Ciprian Stratulat • Updated on Sep 28, 2022

Welcome to another article in our Intro to Programming series. In this article, I'll start diving deeper into what a program is and what it is made of. Particularly, I'll be talking about the concept of data and data types.

In my previous article, you saw your very first Python program, which was a one line of code that printed the text hello world. 


Shown below is an example of printed text in Jupyter notebook: 

print('hello world')

This might seem like a very basic thing to do, but it is a good place to start. I want you to focus on this line of code for a moment. 

Let's ignore the parentheses and the quotes for now. If you took all those symbols out, you'd basically have two parts: the word print, which you can see in red in the screenshot below, and the phrase hello world.

Example of "Print hello world"

Image Source: Edlitera

The word print sounds like an instruction that we want to give to the computer, and that's exactly what it is. By typing the word print, you're basically instructing the computer to print something for us on the screen.

Example of "print hello world" showing "print" is the instruction.

Image Source: Edlitera

That something is the phrase hello world and you can think of it as data. Data is information that a computer program acts on.

Example of "print hello world" showing "hello world" is the data.

Image Source: Edlitera

So, to simplify it a bit, you can think of a computer program as a set of instructions that operate on data to solve a particular problem.

Screenshot of "a computer program = instructions + data"

Image Source: Edlitera

That's really what it is. In its simplest form, a computer program takes data as input, does something to that data using the set of instructions you specified, and outputs a result, or performs some action.

Screenshot of data gives instructions getting a result or action.

Image Source: Edlitera

That data can come from many different sources:


  • User input (someone typing it in at a keyboard, for example)
  • Databases
  • Sensors
  • APIs, etc.  

All programming languages have built-in ways to get data from the outside world. For accessing specialized data sources, the Python community has built packages and released them as open source.

There's an interesting thing about data that you should be aware of, and that is that there are multiple types of it. And here, I want you to keep in mind the distinction between a data source and a data type.

The data source refers to the way the computer program gets the data. Is it from a user typing it at a keyboard? Is it from a file or a database?

The data type refers to what kind of data it is. For example, is the data a number, like number 7? Is it a date, like for example March 17th? Is it text, like hello world? And you might be thinking, that's cool, but why do we need data types? Why do you need to know that some information that was passed to your program is a number or a text?


The reason is simply that you can do different things with different data types. Each data type has some abilities. You can think of them as super-powers.

For example, a number can be subtracted mathematically from another number and you'll get yet another number. But subtracting one word from another makes no sense mathematically. Can you divide the word "hello" by the word "summer?" No, that makes no sense. But you can divide two numbers.

Further complicating things is the fact that computers are not very good at understanding human concepts. If I ask a friend for a favor, say, to print a sheet of paper with the word "print" on it, she will understand what to do. A computer will get very confused.

First of all, a computer would be unable to parse that request, because computers are not yet very good at extracting meaning from human speech. I would have to simplify my request and use a computer language (a programming language).

I could instruct the computer as follows in this example in Jupyter notebook:

print print

The sequence of characters, p-r-i-n-t, appears twice in that request, but which one is the instruction, and which one is the data? To avoid the confusion, I could make an agreement with the computer that I will always use single or double quotes around text, and that everything that is not within quotes should be interpreted as a symbol (for example, an instruction).

So I could then instruct the computer as follows in Jupyter notebook:

print 'print'

This is not valid Python code, but it is valid Ruby code (Ruby is another programming language). Now the computer can make the distinction between the two print words.

So, because all programs that you write are nothing more than sequences of letters and numbers, you need to have a convention, an agreement, between you and the computer about how to interpret different sequences of characters. 

Later in this blog series you'll get acquainted with the various conventions in the Python programming language. For now, I just want you to be aware that these conventions exist and are necessary to avoid confusion.

Let's have a look at some of the basic data types available in Python. Don't worry about memorizing the information in the table below because I will revisit each one of the data types in detail and learn about their special abilities:

List of Data Types in Python with definitions

Image Source: Edlitera

In the table above, there are three columns: one is for the English name of the data type, the second is for the Python name for the data type - you'll notice that it's very similar to the English word, except abbreviated in some cases, and finally the last column provides some examples of data that fits each data type.

If you pay attention, you will also notice the conventions in place for representing that particular data type (e.g. quotes, different kind of parentheses, etc.). Let's start from the top and briefly go over the basic Python data types.


What Are Integers?

The integer data type is reserved for numbers that can be written without a decimal component.

So these are whole numbers and can be both positive and negative, like this example in Jupyter notebook:

20 10 0 -300


What Are Booleans?

The boolean data type can only have one of two values, True or False. I'll go over it in more details in a bit and you'll see that this data type is crucial to writing programming logic.

Here's an example of boolean data using Jupyter notebook:

True False

Article continues below


What Are Floating-Point Numbers?

The floating-point (float) data type is used for numbers that have a decimal component.

An example of floating-point numbers using Jupyter notebook looks like this:

3.14 2.73


What Are Strings?

Next, you have the string data type. You've seen this data type in action already. It's used to represent text like Hello World. Basically, a string is just a collection of characters surrounded by either single quotes or double quotes. You can already notice something interesting: if I use quotes around the integer 2018, it becomes a string. Again, I'll go over strings in more details in a bit.

Here are some examples of strings using Jupyter notebook:

'hello world' "hey88340" '2018'



What Are Lists?

Lists are just lists of items. This data type is incredibly powerful, as you'll see later on in future articles. The general concept of list of items is present in pretty much all programming languages.

However, Python lists, unlike lists in certain other programming languages, can host items of any other data types. For example, you can have lists that contain integers, strings, booleans, and even other lists! Lists are defined by using square brackets with the items separated by commas.

I'll also go over lists in a bit and you'll see they are very powerful. In the meantime, here is a simple example of a list in Jupyter notebook:

[10, '2018', 'hi']



What Are Dictionaries?

Next, you have dictionaries. To understand dictionaries as a Python data type, think of an actual dictionary in, let's say, a Spanish-English dictionary. It has keys, which are the words in Spanish, followed by values, which are the translations in English. The Dictionary data type is based on the same idea: you have keys and each key is followed by a value.

A Python dictionary is written using curly braces with commas separating the key-value pairs. You will see that there are some restrictions with respect to what kind of data types are allowed to be keys. However, values can be any data type.

Below I have an example in Jupyter notebook. Notice that the word diez (a string) is mapped to the integer 10. This is perfectly ok.

{"la tarde": "afternoon", "noche": "night", "diez": 10}



What Are Tuples?

And last, but not least, you have tuples. Tuples are very similar to lists, except you write them between parentheses instead of square brackets. You'll learn how they are different from lists and why they're important later in the course.

Here's a tuple example shown using Jupyter notebook:

(10, 20.0, 'world', -5)



There are, of course, other data types, but these are the fundamental ones I will cover in this blog series. If you are comfortable using these, you will be able to understand any other data type you might encounter in your programming career.

Again, don't worry too much about the specifics right now, as this is just a preview. I'll cover each data type in detail in the following articles. For now, it's important to remember that programs are sets of instructions that operate on data, and that data can have multiple data sources (such as user input, variables, databases, files, etc.). Also, each piece of data has a certain data type and that's important because different data types have different super-powers.


Ciprian Stratulat

CTO | Software Engineer

Ciprian Stratulat

Ciprian is a software engineer and the CTO of Edlitera. As an instructor, Ciprian is a big believer in first building an intuition about a new topic, and then mastering it through guided deliberate practice.

Before Edlitera, Ciprian worked as a Software Engineer in finance, biotech, genomics and e-book publishing. Ciprian holds a degree in Computer Science from Harvard University.