Learnmonkey Learnmonkey Logo
× Warning:

The tutorial you are reading is currently a work in-progress.

Data Types in Python

What is a Data Type?

In Python, the data stored in variables can be stored in many different forms. These forms are called data types. There are two different types of data types: the default ones and the custom ones. This tutorial will be covering basic and common default data types.

Strings

One of the most important data types in all of Python is the string. Put simply, strings are just some text. When we learned to make our very first Python program, we learned that we must wrap text in double or single quotes. Strings are simply the text we wrapped in quotes.

If you have trouble remembering this, think of strings as strings of characters.

Integers

Integers are simply whole numbers, which can be positive or negative. They cannot be decimals. Simple as that. We do not need to wrap them in quotes and we can do arithmetic with them.

Floats

Floats are basically the same as integers and we can do the same things with them. The only difference is that floats are decimals. Floats are an abbreviation of floating point numbers.

Booleans

Although the name might sound exotic, booleans are actually incredibly simple. They are just true or false. Computers are made with trues and falses (also known as ones and zeros) so you'd imagine that booleans are a very important data type.

To make a boolean have the value of true, we simply type the word "true" but capitalized. So, True. For false, we type False.

Booleans are named after the English mathematician George Boole.

None

None is basically just a placeholder when there is nothing. None is actually its own data type, NoneType. It may seem awkward since None is sort of like a boolean, but None is actually a different data type.

Getting the Type

To get the type of a variable, we type type(), where you put the variable you want to get the type of in the brackets.