Data Types and Variables

Understanding the different data types and the concept of the variable

Data Type?

A data type is a type of data. It decides what type of data is being used or stored. Types of data types in Python include integers, strings, and floating points.


Integers are a data type used for representing and storing, well, numeric values that are integers!!! (-49, -10, -2, 0, 3, 5, 459, etc). In programming languages, arithmetic operations (addition, subtraction, multiplication, division, etc) can be done as expected on data of this type. This type is also typically used for indexing lists and other core functions of programming languages, which we will cover later.


A string is a data type used in programming that is used to represent text. A string can consist of a set of characters including spaces and numbers. In Python, and in most other languages, we represent strings by putting the characters between double quotes. For e.g. "dog", "I am happy!", "I am the number 5", ":) means happy!", etc.

Floating Point Numbers

Floating point numbers are another data type. They are also used to represent numeric values like integers, but can have decimal values. They can also have arithmetic operations done on them.


Booleans are a data type of two values: "True" or "False". We will use them a lot in control flow and if/else statements, which we will cover in a later lesson.


The variable is a central concept to programming. It is important that you understand it. Variables are used to store information that can be later used or changed in a computer program. They also provide a way of giving data a descriptive name, so our programs are easier to understand. Think of variables as containers that hold something. That something is information. The purpose of these containers is to label and store data in memory. This data can then be used throughout your program. Also, the information in the container can always be modified or changed, hence the name, variable (like in Algebra). In Python, we create a variable by giving it a name, followed by ‘=’ and the information to fill the variable with. This could be an integer, float, or string, as we discussed earlier. Remember, how we discussed commands in Python code. Assigning a value to a variable is considered such a command, so it gets its own line. Basically, every individual part of code in Python should get its own line. Here’s an example of assigning variable different values...

Number_variable = 5
String_variable = "This is a string"
var_filled_with_a_float = 17.35

It may seem a bit confusing right now, but you will see how these become useful soon. Also, do note that the names chosen above are completely random. You can pick whatever name you want. If you ever want to use this variable, like we said, you just need to write the variable’s name, you don’t need to write the value, because that’s what the variable is for! For example...

Course_name = "Python"

Once run, the output should look like this…


Don’t worry about what you haven’t learned, we’ll go over the print() function and how to run programs later.